CAROLINA DOCS


Logger

The "logger" app provides a service that allows for making log entries. It does so by maintaining a winston instance.

The Logger Service

When the "logger" app is loaded, winston is configured to write to logs/app.log and logs/error.log within the filesDir directory specified in config/disk.js.

Once it has been loaded, the winston instance can be accessed as logger:

let winstonInstance = App.$logger.logger;

The "logger" service provides shorcut methods for making log statements at each of the 6 NPM log levels:

App.$logger.silly("This is unimportant.");
App.$logger.debug("This is very specific information.");
App.$logger.verbose("This is more information than you might need.");
App.$logger.info("This is information you should be aware of.");
App.$logger.warn("Something might be wrong.");
App.$logger.error("Something is very wrong.");

Configuration

The default configuration for the "logger" app looks like this:

module.exports = {
// NPM log level to use
logLevel: 'debug',
// whether or not to output console logs when in debug mode
logToConsoleInDebug: true,
// whether or not to output file logs
logToFiles: true
};

The logging methods will ignore all log statements at a level less severe than what is specified by logLevel. If logToConsoleInDebug is true and the app is in debug mode, log statements will be printed to the terminal. If logToFiles is true, log statements will be written to files as well.

Publishable Files

You can publish a config file for the "logger" app to config/logger.js using the following command:

node . publish --config logger

CAROLINA DOCS