Module: fs-error-logger

Writes errors into files in both JSON and XML.

Version:
  • 1.0.2
Author:
  • Pedro Miguel P. S. Martins
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
deps Object
Properties
Name Type Description
fs Object

File system object that allows the logger to
write the files. Must have an async
writeFile function and an async
mkdir function.

opts module: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
error Error

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
error Error

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
newFn function

A new Id generator function.

Source:
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.

Source:
Throws:

If newFolder is not a string.

Type
PathNotAString

Type Definitions


options

Options object determining output folder and id generator function.

Type:
  • Object
Properties:
Name Type Argument Default Description
outputFolder string <optional>
"."

The default output folder.

idFn function <optional>
Date.now

The default id generator
function.

Source: