Writes errors into files in both JSON and XML.
- Version:
-
- 1.0.2
- Source:
Methods
-
<static> logger(deps [, opts])
-
Returns a logger object, with the API that allows you to write errors to files.
Parameters:
Name Type Argument Description depsObject Properties
Name Type Description fsObject File system object that allows the logger to
write the files. Must have an async
writeFilefunction and an async
mkdirfunction.optsmodule:fs-error-logger~options <optional>
Options object determining output folder and
id generator function.- Source:
Returns:
- Type
- Object
-
<inner> getIdFn()
-
Returns the current id generator function.
- Source:
Returns:
- Type
- function
-
<inner> getOutputFolder()
-
Returns the current output folder path.
- Source:
Returns:
- Type
- string
-
<inner> logJSON(error)
-
Resolves if the error was successfully written to a JSON file or rejects otherwise. The format of the file will be:
${error.name}_${idFn()}.json.Parameters:
Name Type Description errorError The error object we want to write.
- Source:
Returns:
- Type
- Promise
-
<inner> logXML(error)
-
Resolves if the error was successfully written to a XML file or rejects otherwise. The format of the file will be:
${error.name}_${idFn()}.xml.Parameters:
Name Type Description errorError The error object we want to write.
- Source:
Returns:
- Type
- Promise
-
<inner> setIdFn(newFn)
-
Sets the current Id generator function to the one given.
Parameters:
Name Type Description newFnfunction A new Id generator function.
- Source:
Throws:
-
If
newFnis not a function. - Type
- IdFnNotAFunction
-
<inner> setOutputFolder(newFolder)
-
Sets the output folder path to the one passed.
Parameters:
Name Type Description newFolderstring The path of the output folder.
- Source:
Throws:
-
If
newFolderis not a string. - Type
- PathNotAString
Type Definitions
-
options
-
Options object determining output folder and id generator function.
Type:
- Object
- Source:
Properties:
Name Type Argument Default Description outputFolderstring <optional>
"." The default output folder.
idFnfunction <optional>
Date.now The default id generator
function.