LogMan

LogMan

Provides an easy to use logging functionality Outputs to the console and to a file (if enabled) This class is to be used as a manager, represents a log. To log to that log, use `getLogger` to return a `Logger` that can be used to actual log data. ```javascript const LogMan = require('logman'); var myLog = LogMan("application"); var securityLogger = myLog.getLogger("SecurityObj"); var miscLogger = myLog.getLogger("Misc"); securityLogger.info("Security looking good!"); // Outputs: [Security][Info] Security looking good! miscLogger.warn("Something went wrong!"); // Outputs: [Misc][Warn] Something went wrong! ``` You can log any string, but note if you pass an object we'll _try_ our best to print it using `Util.inspect` Close event tells you this logger is done. Events for each level, such as `logMan.on('info', (sectionName, message) => console.log);` Or for generic logs: `logMan.on('log', (level, sectionName, message) => console.log);` When a call to getLogger() is made: `logMan.on('newLogger', (loggerName) => console.log);`

Constructor

new LogMan(logName, logFolderopt, optionsopt)

Constructor, provide the folder containing the logs and name of this log. Logs are saved as: logFolder/logName.log
Source:
Parameters:
Name Type Attributes Default Description
logName string
logFolder string <optional>
"."
options ConstructorOptions <optional>

Members

consoleBeepOnLevel :logLevelsBoolean

Which levels to make a ding sound on (output bell character at the end of the console suffix)
Source:
Type:

consoleDisplayLevel :logLevelsBoolean

Which levels to output to the console, (default is all, except debug and silly if `process.env.NODE_ENV !== "development"`)
Source:
Type:

consoleMessageCharacterLimit :int

The maximum number of characters we'll print to the console each message.
Source:
Type:
  • int

consoleMessageCharacterLimitString :string

This is the string appended on to a message that we've fit to the consoleMessageCharacterLimit. That is, if your message is too long we'll truncate it fit within your limit and add this string to the end to signal the string was truncated.
Source:
Type:
  • string

consolePrefix :string

String of text at the front of ALL messages. You can include %date% for the date and %time% for the time %logName% for the name of this log ` message `
Source:
Type:
  • string

consolePrefixes :logLevelsString

String in front of messages logged to the console ` message `
Source:
Type:

consoleSufix :string

String of text at the end of ALL messages (reset color) ` message `
Source:
Type:
  • string

consoleSufixes :logLevelsString

String at the end of messages logged to the console ` message `
Source:
Type:

fileLineTerminator

New line character in log file `\r\n` for Win32 `\n` for not Win32
Source:

fileMessageCharacterLimit :int

The maximum number of characters written out each log message to the file.
Source:
Type:
  • int

fileMessageCharacterLimitString :string

This is the string appended on to a message that we've fit to the fileMessageCharacterLimit. That is, if your message is too long we'll truncate it fit within your limit and add this string to the end to signal the string was truncated.
Source:
Type:
  • string

filePrefix :string

String of text at the front of ALL messages written to FILE You can include %date% for the date and %time% for the time %logName% for the name of this log ` message `
Source:
Type:
  • string

filePrefixes :logLevelsString

String in front of messages written to the file ` message `
Source:
Type:

fileSufix :string

String of text at the end of ALL messages written to FILE ` message `
Source:
Type:
  • string

fileSufixes :logLevelsString

String at the end of messages written to the file ` message `
Source:
Type:

fileWriteLevel :logLevelsBoolean

Which log levels are written to the log file (default is all, except debug and silly if `process.env.NODE_ENV !== "development"`)
Source:
Type:

objectRenderDepth :number

When logging objects, this dictates how deep we render the object. Default 2
Source:
Type:
  • number

outputToConsole :boolean

Whether we output to the console. True by default
Source:
Type:
  • boolean

outputToFile :boolean

Whether we output to the console. True by default
Source:
Type:
  • boolean

Methods

close()

Closes the log file, no logging is permitted to file OR console after this. You can reopen via `Logger.reopen()` Only works if `this.outputToFile` is true.
Source:
Fires:
  • LogMan#event:close

getLogger(loggerName, hideSectionNameopt) → {Logger}

Gives you a logger object so you can actually log data out.
Source:
Parameters:
Name Type Attributes Description
loggerName string Name of this logger (section, class)
hideSectionName boolean <optional>
Allows you to hide the name of this logger
Fires:
  • Logger#event:newLogger
Returns:
Type:
Logger
Logger instance

open()

Reopens the log files. Permits logging if previously closed.
Source: