File logging module for good process monitoring.
Lead Maintainer: Adam Bretz
good-file
is a good reporter implementation to write hapi server events to the local file system.
Creates a new GoodFile object where:
events
- an object of key value pairs.key
- one of the supported good events indicating the hapi event to subscribe tovalue
- a single string or an array of strings to filter incoming events. "*" indicates no filtering.null
andundefined
are assumed to be "*"
config
- specifications for the file that will be used. All file operations are done in "append" mode.String
- a string that indicates the log file to use. Opened in "append" mode.Object
- a configuration object for automatically generated files. Auto generated files use the following pattern for file naming: "{options.prefix
}-{utcTime.format(options.format
)}-{random string}.{settings.extension
}"path
- required. Path to the directory to store log files.[format]
- a MomentJs format string. Defaults to "YYYY-MM-DD".[extension]
- file extension to use when creating a file. Defaults to ".log". Set to "" for no extension.[prefix]
- file name prefix to use when creating a file. Defaults to "good-file"[rotate]
- a string indicating a log rotation time span. The designated time span will start a timer that will trigger at the end of the specified time span. For example, using "daily", a new log file would be created at approximately 11:59:59.999 on the current day. Please see this section in the Moment.js documentation for more details. The string must be one of the following values: ['hourly', 'daily', 'weekly', 'monthly'].
Limitations A new file is always created when the process starts, regardless of
rotate
option; this is to prevent collisions. So if you start and stop the process several times in a row, there will be a new file created each time and a new timer will start at the beginning of the process. There are several time related precision issues when working with JavaScript. The log rotation will happen "close enough" to the desiredrotate
option.
Initializes the reporter with the following arguments:
stream
- a Node readable stream that will be the source of data for this reporter. It is assumed thatstream
is inobjectMode
.emitter
- an event emitter object.callback
- a callback to execute when the start function has complete all the necessary set up steps and is ready to receive data.