Module: logger

A logger module, it allows for different levels of logging and to save a log file and/or output the log to console.
Version:
  • 0.0.2
Author:
  • Danilo Del Busso

Methods


<inner> append(element)

Append an element to the log file.
Parameters:
Name Type Description
element Object the element to be appended to the log file

<inner> argumentsToArray(args)

Convert the JSON file created by calling the "arguments" variable inside a function with no parameters, to an array
Parameters:
Name Type Description
args JSON the JSON file created by calling the "arguments" variable inside a function with no parameters7
Returns:
an array containing the values of the JSON file. Empty if the args JSON was not valid.
Type
array

<inner> changeOption(optionName, value)

Change an existing option value. If the option does not exist, nothing is changed. If the value does not have the same type as the value that needs to be changed, nothing is changed.
Parameters:
Name Type Description
optionName string the name of the existing options.
value Object the new value of the option.
Returns:
the new value of the option. null if the parameters are not valid.
Type
Object

<inner> convertToString(obj)

Convert any object to a string If the object is a JSON file, use the stringify() function. Else, use the String(obj)
Parameters:
Name Type Description
obj Object the object to be converted to a string
Returns:
the object converted to string
Type
string

<inner> createLog(messages, level)

Log all the strings or objects contained using the options configuration.
Parameters:
Name Type Description
messages array the set of objects
level string

<inner> debug()

Use to create a debugging log message. It takes any number of parameters

<inner> deleteAllLogFiles()

Flush the content of every log file and delete them.

<inner> deleteFolderRecursive(path)

Recursively and synchronously delete all files inside a path. taken from https://bit.ly/2TqLDWv
Parameters:
Name Type Description
path string

<inner> deleteLogFile()

Flush the content of the log file. And delete it.

<inner> error()

Use to create a error log message. It takes any number of parameters

<inner> getLogPath(outputPath)

Generate the log path for this module
Parameters:
Name Type Description
outputPath string the output path

<inner> info()

Use to create a info log message. It takes any number of parameters

<inner> initialise(configPath)

Generate the options for the use of this module and create a write stream. If the path of the config is not valid, use a set of default options.
Parameters:
Name Type Description
configPath string the path of the config file.
Returns:
the options for logging.
Type
JSON

<inner> log()

Use to create a general log message. It takes any number of parameters

<inner> warning()

Use to create a warning log message. It takes any number of parameters