Skip to content

Commit

Permalink
Closes #848: Limit Length of File Lines Logged (#1563)
Browse files Browse the repository at this point in the history
This PR (Closes #848):
- Adds limit to length of file/dset names logged

I had no idea what n should be. I made it 1000 characters (so lengths > 2000 are truncated) because that seemed reasonable to me. I'm certainly open to suggestions for different values

If I could get ethan's help testing this, that would be awesome!

Co-authored-by: Pierce Hayes <[email protected]>
  • Loading branch information
stress-tess and Pierce Hayes authored Jul 11, 2022
1 parent fb8bc8d commit 6ea2918
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/FileIO.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,10 @@ module FileIO {
try {
filelist = jsonToPdArray(jsonfiles, nfiles);
} catch {
var errorMsg = "Could not decode json filenames via tempfile (%i files: %s)".format(nfiles, jsonfiles);
// limit length of file names to 2000 chars
var n: int = 1000;
var files: string = if jsonfiles.size > 2*n then jsonfiles[0..#n]+'...'+jsonfiles[jsonfiles.size-n..#n] else jsonfiles;
var errorMsg = "Could not decode json filenames via tempfile (%i files: %s)".format(nfiles, files);
return new MsgTuple(errorMsg, MsgType.ERROR);
}

Expand Down
10 changes: 8 additions & 2 deletions src/HDF5Msg.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -1821,16 +1821,22 @@ module HDF5Msg {
try {
dsetlist = jsonToPdArray(jsondsets, ndsets);
} catch {
// limit length of dataset names to 2000 chars
var n: int = 1000;
var dsets: string = if jsondsets.size > 2*n then jsondsets[0..#n]+'...'+jsondsets[jsondsets.size-n..#n] else jsondsets;
var errorMsg = "Could not decode json dataset names via tempfile (%i files: %s)".format(
ndsets, jsondsets);
ndsets, dsets);
h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg);
return new MsgTuple(errorMsg, MsgType.ERROR);
}

try {
filelist = jsonToPdArray(jsonfiles, nfiles);
} catch {
var errorMsg = "Could not decode json filenames via tempfile (%i files: %s)".format(nfiles, jsonfiles);
// limit length of file names to 2000 chars
var n: int = 1000;
var files: string = if jsonfiles.size > 2*n then jsonfiles[0..#n]+'...'+jsonfiles[jsonfiles.size-n..#n] else jsonfiles;
var errorMsg = "Could not decode json filenames via tempfile (%i files: %s)".format(nfiles, files);
h5Logger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg);
return new MsgTuple(errorMsg, MsgType.ERROR);
}
Expand Down
15 changes: 12 additions & 3 deletions src/ParquetMsg.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -559,16 +559,22 @@ module ParquetMsg {
try {
dsetlist = jsonToPdArray(jsondsets, ndsets);
} catch {
// limit length of dataset names to 2000 chars
var n: int = 1000;
var dsets: string = if jsondsets.size > 2*n then jsondsets[0..#n]+'...'+jsondsets[jsondsets.size-n..#n] else jsondsets;
var errorMsg = "Could not decode json dataset names via tempfile (%i files: %s)".format(
1, jsondsets);
ndsets, dsets);
pqLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg);
return new MsgTuple(errorMsg, MsgType.ERROR);
}

try {
filelist = jsonToPdArray(jsonfiles, nfiles);
} catch {
var errorMsg = "Could not decode json filenames via tempfile (%i files: %s)".format(nfiles, jsonfiles);
// limit length of file names to 2000 chars
var n: int = 1000;
var files: string = if jsonfiles.size > 2*n then jsonfiles[0..#n]+'...'+jsonfiles[jsonfiles.size-n..#n] else jsonfiles;
var errorMsg = "Could not decode json filenames via tempfile (%i files: %s)".format(nfiles, files);
pqLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg);
return new MsgTuple(errorMsg, MsgType.ERROR);
}
Expand Down Expand Up @@ -881,7 +887,10 @@ module ParquetMsg {
try {
filelist = jsonToPdArray(jsonfiles, nfiles);
} catch {
var errorMsg = "Could not decode json filenames via tempfile (%i files: %s)".format(nfiles, jsonfiles);
// limit length of file names to 2000 chars
var n: int = 1000;
var files: string = if jsonfiles.size > 2*n then jsonfiles[0..#n]+'...'+jsonfiles[jsonfiles.size-n..#n] else jsonfiles;
var errorMsg = "Could not decode json filenames via tempfile (%i files: %s)".format(nfiles, files);
pqLogger.error(getModuleName(),getRoutineName(),getLineNumber(),errorMsg);
return new MsgTuple(errorMsg, MsgType.ERROR);
}
Expand Down

0 comments on commit 6ea2918

Please sign in to comment.