Module: logger

Writes errors into files in both JSON and XML.
Version:
  • 1.0.0
Author:
  • Pedro Miguel P. S. Martins

Methods


<inner> getIdFn()

Returns the current id generator function.
Returns:
Type
function

<inner> getOutputFolder()

Returns the current output folder path.
Returns:
Type
string

<inner> loggerFactory(opts)

Returns a logger object with all the dependencies pre-injected and with the given options, ready to use.
Parameters:
Name Type Description
opts Object
Properties
Name Type Argument Default Description
outputFolder string <optional>
"."
idFn function <optional>
Date.now
Returns:
Type
logger

<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
error Error The error object we want to write.
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
error Error The error object we want to write.
Returns:
Type
Promise

<inner> setIdFn(newFn)

Sets the current Id generator function to the one given.
Parameters:
Name Type Description
newFn function A new Id generator function.
Throws:
If newFn is not a function.
Type
IdFnNotAFunction

<inner> setOutputFolder(newFolder)

Sets the output folder path to the one passed.
Parameters:
Name Type Description
newFolder string The path of the output folder.
Throws:
If newFolder is not a string.
Type
PathNotAString