Releases: harrisonhoward/forbidden-node-logger
Improved Typings Support
Includes better typings, will change how you create a new Logger.
const NodeLogger = require("forbidden-node-logger");
cont Logger = new NodeLogger.Logger();
import * as NodeLogger from "forbidden-node-logger";
const Logger = new NodeLogger.Logger();
Log Type Support
With this new version the Log structure now takes a type (none, info, debug, warn or error)
Using Logger.log()
will allow you to set the type (not required by any code check will error) Logger.log("error", "Log type is error")
info(), debug(), warn() and error() will set the type
eventLog() has the same change
Setting the type to warn
or error
will not emit an event only the method variants will. This change was designed for allowing filtering the collection by the type of log.
Note:
Doing Logger.log("this", " is my ", "log")
will set the type to "none" and prepend "this" to the log.
This means you are not required to enter a type, if you don't anything you enter automatically gets prepend and type set to none.
Upgraded File Support
Warnings and Errors can their own dedicated file.
dd-warn.log
and dd-error.log
More methods for retrieving logs
getLogByDay(day?, month?, year?); Will return an array of lines from the specified log.
getLogsByMonth(month?, year?); Will return an object containing the day and it's log. { '4': ["Lines"], '5': ["Lines"] }
getLogsByYear(year?); Will return an object containing the month and it's days which hold the lines { '9': { '4': ["Lines"], '5': ["Lines"] } }
_prefix: string -> _prefix: LoggerPrefixFunction
Fixe for a missed typed _prefix
Typings Declaration
Added a TypeScript Typings Declaration file for TypeScript users.
Some other changes include:
getCurrentLog() -> getLatestLog()
Support for Errors
With this new release, many formatting and general code fixes were made. This was under the hood stuff and won't change what you see.
However, I have added proper support for errors, this works for the collection and the file history as expected.
Official Release
README.md