🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@stgdp/fancy-logger

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stgdp/fancy-logger - npm Package Compare versions

Comparing version
1.0.0-beta.4
to
1.0.0
+33
-8
CHANGELOG.md
# Changelog
## [Unreleased]
## [1.0.0]
### Security
- Updated mocha to 8.2.1
- Updated `mocha` to 10.0.0
- Updated `fecha` to 4.2.3
- Updated `strip-ansi` to 6.0.1
### Added
- Implemented modifier options to `write` method
- Implemented linting for improved coding standards
- Commented code for easier understanding
### Changed
- Refactored tests - [#6]
- Updated shields
- Migrated from `travis-ci.com` to Github Actions
## [1.0.0-beta.4] - 2020-11-25
### Security
- Updated `mocha` to 8.2.1
### Added
- Implemented default modifiers - [#4]
### Changed
- Migrated CI to `travis-ci.com`
## [1.0.0-beta.3] - 2020-11-11
### Added
- Implemented writing the log to a file
- Implemented writing the log to a file - [#2] [#3]

@@ -31,3 +54,2 @@ ### Changed

### Added
- Implemented basic mocha tests

@@ -40,3 +62,2 @@ - Timestamps can now be disabled

### Changed
- Converted the logger to a class instead of a function with prototypes

@@ -47,3 +68,2 @@ - Implemented more checks to the `modifier`, `reset` and `output` methods

### Fixed
- Fixed issues with the bright colors on the `fg` and `bg` methods

@@ -54,6 +74,6 @@

### Added
- Initial (beta) version
[unreleased]: https://github.com/stgdp/fancy-logger/compare/v1.0.0-beta.3...HEAD
[1.0.0]: https://github.com/stgdp/fancy-logger/releases/tag/v1.0.0
[1.0.0-beta.4]: https://github.com/stgdp/fancy-logger/releases/tag/v1.0.0-beta.4
[1.0.0-beta.3]: https://github.com/stgdp/fancy-logger/releases/tag/v1.0.0-beta.3

@@ -63,1 +83,6 @@ [1.0.0-beta.2]: https://github.com/stgdp/fancy-logger/releases/tag/v1.0.0-beta.2

[1.0.0-beta.0]: https://github.com/stgdp/fancy-logger/releases/tag/v1.0.0-beta.0
[#6]: https://github.com/stgdp/fancy-logger/issues/6
[#4]: https://github.com/stgdp/fancy-logger/issues/4
[#3]: https://github.com/stgdp/fancy-logger/issues/3
[#2]: https://github.com/stgdp/fancy-logger/issues/2
+306
-94

@@ -1,18 +0,100 @@

const fs = require( "fs" )
const path = require( "path" )
// Core dependencies
const fs = require( 'fs' )
const path = require( 'path' )
const ansi_codes = require( "@stgdp/ansi-codes" )
const strip_ansi = require( "strip-ansi" )
const timestamp = require( "fecha" ).format
// External dependencies
const ansi_codes = require( '@stgdp/ansi-codes' )
const strip_ansi = require( 'strip-ansi' )
const timestamp = require( 'fecha' ).format
/**
* Logger default options
* @typedef {object} LoggerDefaultOptions
* @property {boolean} timestamp - Enables the timestamp
* @property {string} format - Sets the format for the timestamp
* @property {boolean} buffer - Buffers the output to be returned or outputted at a later
* @property {boolean|string} file - Sets a file to store the current log buffer to when `to_file` is called
* @property {object} file_options - Sets the file options for the `to_file` method. Gets passed to `fs.writeFileSync`
* @property {object} modifiers - Sets the default modifiers for the logger to run with
* @property {boolean|string} modifiers.fg - The foreground color for the logger
* @property {boolean|string} modifiers.bg - The background color for the logger
* @property {object} modifiers.bright - The brightness options for the foreground and background
* @property {boolean} modifiers.bright.fg - Whether the foreground should be bright
* @property {boolean} modifiers.bright.bg - Whether the foreground should be bright
* @property {object} modifiers.decoration - The decoration options for the logger
* @property {boolean} modifiers.decoration.bold - Sets the logger to be bold
* @property {boolean} modifiers.decoration.bold - Sets the logger to be bold
* @property {boolean} modifiers.decoration.dim - Sets the logger to be dim
* @property {boolean} modifiers.decoration.italic - Sets the logger to be italic
* @property {boolean} modifiers.decoration.underline - Sets the logger to be underline
* @property {boolean} modifiers.decoration.inverse - Sets the logger to be inverse
* @property {boolean} modifiers.decoration.hidden - Sets the logger to be hidden
* @property {boolean} modifiers.decoration.strike - Sets the logger to be strike
* @property {boolean} modifiers.decoration.frame - Sets the logger to be frame
* @property {boolean} modifiers.decoration.encircle - Sets the logger to be encircle
* @property {boolean} modifiers.decoration.overline - Sets the logger to be overline
*/
/**
* Logger default options w/ reset options
* @typedef {object} LoggerDefaultOptionsReset
* @property {boolean} timestamp - Enables the timestamp
* @property {string} format - Sets the format for the timestamp
* @property {boolean} buffer - Buffers the output to be returned or outputted at a later
* @property {boolean|string} file - Sets a file to store the current log buffer to when `to_file` is called
* @property {object} file_options - Sets the file options for the `to_file` method. Gets passed to `fs.writeFileSync`
* @property {object} modifiers - Sets the default modifiers for the logger to run with
* @property {boolean|string} modifiers.fg - The foreground color for the logger
* @property {boolean|string} modifiers.bg - The background color for the logger
* @property {object} modifiers.bright - The brightness options for the foreground and background
* @property {boolean} modifiers.bright.fg - Whether the foreground should be bright
* @property {boolean} modifiers.bright.bg - Whether the foreground should be bright
* @property {object} modifiers.decoration - The decoration options for the logger
* @property {boolean} modifiers.decoration.bold - Sets the logger to be bold
* @property {boolean} modifiers.decoration.bold - Sets the logger to be bold
* @property {boolean} modifiers.decoration.dim - Sets the logger to be dim
* @property {boolean} modifiers.decoration.italic - Sets the logger to be italic
* @property {boolean} modifiers.decoration.underline - Sets the logger to be underline
* @property {boolean} modifiers.decoration.inverse - Sets the logger to be inverse
* @property {boolean} modifiers.decoration.hidden - Sets the logger to be hidden
* @property {boolean} modifiers.decoration.strike - Sets the logger to be strike
* @property {boolean} modifiers.decoration.frame - Sets the logger to be frame
* @property {boolean} modifiers.decoration.encircle - Sets the logger to be encircle
* @property {boolean} modifiers.decoration.overline - Sets the logger to be overline
* @property {object} modifiers.reset - The reset options for the logger
* @property {boolean} modifiers.reset.all - Resets the modifiers in the logger
* @property {boolean} modifiers.reset.bold - Resets the bold decoration in the logger
* @property {boolean} modifiers.reset.dim - Resets the dim decoration in the logger
* @property {boolean} modifiers.reset.italic - Resets the italic decoration in the logger
* @property {boolean} modifiers.reset.underline - Resets the underline decoration in the logger
* @property {boolean} modifiers.reset.inverse - Resets the inverse decoration in the logger
* @property {boolean} modifiers.reset.hidden - Resets the hidden decoration in the logger
* @property {boolean} modifiers.reset.strike - Resets the strike decoration in the logger
* @property {boolean} modifiers.reset.reset_fg - Resets the foreground modifier in the logger
* @property {boolean} modifiers.reset.reset_bg - Resets the background modifier in the logger
* @property {boolean} modifiers.reset.frame - Resets the frame decoration in the logger
* @property {boolean} modifiers.reset.encircle - Resets the encircle decoration in the logger
* @property {boolean} modifiers.reset.overline - Resets the overline decoration in the logger
*/
/**
* Class representing the logger
* @property {object} stdout - Reference to `process.stdout`
* @property {object} _options - The parsed logger options
* @property {string} _output - The output, stored to a string
* @property {string} _modifier - The modifier type to apply
* @property {boolean} _bright - Whether the foreground/background should be bright
*/
class Logger {
constructor ( options ) {
/**
* Create a logger instance
* @param {LoggerDefaultOptions} options - The logger options
*/
constructor( options ) {
this.stdout = process.stdout
this._options = options
this._output = ""
this._modifier = ""
this._options = parse_options.call( this, options )
this._output = ''
this._modifier = ''
this._bright = false
parse_options.call( this )
if ( this._options.timestamp ) {

@@ -22,6 +104,21 @@ write_timestamp.call( this )

set_modifiers.call( this )
set_modifiers.call( this, this._options.modifiers )
}
write( data ) {
/**
* Outputs provided content
* @param {string|string[]} data - The content to write out
* @param {object} modifiers - Modifiers to set for the logger. See https://github.com/stgdp/fancy-logger#default-modifiers and https://github.com/stgdp/fancy-logger#reset
* @returns {Logger}
*/
write( data, modifiers = {} ) {
// Parse & output any set modifiers
modifiers = parse_modifiers.call( this, modifiers, true )
set_modifiers.call( this, modifiers )
// Joins array to string for output
if ( Array.isArray( data ) ) {
data = data.join( ' ' )
}
this._output += data

@@ -36,7 +133,15 @@

/**
* Resets the modifiers and writes a newline
* @returns {Logger}
*/
get end() {
this.all.write( "\n" )
this.all.write( '\n' )
return this
}
/**
* Outputs the buffer to file if the buffer is enabled
* @returns {Logger}
*/
get output() {

@@ -50,2 +155,6 @@ if ( this._options.buffer ) {

/**
* Returns the logger output
* @returns {string}
*/
get return() {

@@ -55,18 +164,20 @@ return this._output

/**
* Write the output to a file
* @param {string} file - The location to save the file
* @returns {Logger}
*/
to_file( file = false ) {
if ( file == false ) {
if ( !file ) {
file = this._options.file
}
if ( typeof file !== "string" || !file ) {
if ( typeof file !== 'string' || !file ) {
return this
}
while ( true ) {
try {
write_file.call( this, file )
break
} catch ( err ) {
throw err
}
try {
write_file.call( this, file )
} catch ( error ) {
throw error
}

@@ -77,2 +188,6 @@

/**
* Sets the foreground/background modifier to be bright
* @return {Logger}
*/
get bright() {

@@ -84,6 +199,11 @@ this._bright = !this._bright

function default_options() {
return {
/**
* Returns the default options for the logger
* @param {boolean} reset - Adds the reset options to the default options
* @returns {LoggerDefaultOptions|LoggerDefaultOptionsReset}
*/
function default_options( reset = false ) {
let options = {
timestamp: true,
format: "HH:mm:ss",
format: 'HH:mm:ss',
buffer: false,

@@ -110,60 +230,89 @@ file: false,

overline: false,
}
},
},
}
if ( reset ) {
options.modifiers.reset = {
all: false,
bold: false,
dim: false,
italic: false,
underline: false,
inverse: false,
hidden: false,
strike: false,
reset_fg: false,
reset_bg: false,
frame: false,
encircle: false,
overline: false,
}
}
return options
}
function parse_options() {
let options = this._options
/**
* Parses the options supplied with the default options
* @param {LoggerDefaultOptions|LoggerDefaultOptionsReset} options - The options to be parsed
* @param {boolean} reset - Whether to parse the reset options
* @returns {LoggerDefaultOptions|LoggerDefaultOptionsReset}
*/
function parse_options( options, reset = false ) {
let parsed_options = default_options()
if ( typeof options !== "object" || !options ) {
this._options = parsed_options
return
if ( typeof options !== 'object' || !options ) {
return parsed_options
}
if ( typeof options.timestamp === "boolean" ) {
if ( typeof options.timestamp === 'boolean' ) {
parsed_options.timestamp = options.timestamp
}
if ( typeof options.format === "string" ) {
if ( typeof options.format === 'string' ) {
parsed_options.format = options.format
}
if ( typeof options.buffer === "boolean" ) {
if ( typeof options.buffer === 'boolean' ) {
parsed_options.buffer = options.buffer
}
if ( typeof options.file === "string" ) {
if ( typeof options.file === 'string' ) {
parsed_options.file = options.file
}
if ( typeof options.file_options === "object" && options.file_options ) {
if ( typeof options.file_options === 'object' && options.file_options ) {
parsed_options.file_options = options.file_options
}
parsed_options.modifiers = parse_modifiers.call( this )
parsed_options.modifiers = parse_modifiers.call( this, options.modifiers, reset )
this._options = parsed_options
return parsed_options
}
function parse_modifiers() {
let modifiers = this._options.modifiers
let parsed_modifiers = default_options().modifiers
/**
* Parses the modifier supplied with the default options
* @param {LoggerDefaultOptions.modifiers|LoggerDefaultOptionsReset.modifiers} modifiers - The modifiers to be parsed
* @param {boolean} reset - Whether to parse the reset options
* @returns {LoggerDefaultOptions.modifiers|LoggerDefaultOptionsReset.modifiers}
*/
function parse_modifiers( modifiers, reset ) {
let parsed_modifiers = default_options( reset ).modifiers
if ( typeof modifiers !== "object" || !modifiers ) {
if ( typeof modifiers !== 'object' || !modifiers ) {
return parsed_modifiers
}
if ( typeof modifiers.fg === "string" ) {
if ( typeof modifiers.fg === 'string' ) {
parsed_modifiers.fg = modifiers.fg
}
if ( typeof modifiers.bg === "string" ) {
if ( typeof modifiers.bg === 'string' ) {
parsed_modifiers.bg = modifiers.bg
}
if ( Array.isArray( modifiers.bright ) || ( typeof modifiers.bright === "object" && modifiers.bright ) ) {
if ( Array.isArray( modifiers.bright ) || ( typeof modifiers.bright === 'object' && modifiers.bright ) ) {
if ( Array.isArray( modifiers.bright ) ) {
modifiers.bright.forEach( function ( item ) {
modifiers.bright.forEach( ( item ) => {
if ( item in parsed_modifiers.bright ) {

@@ -175,3 +324,3 @@ parsed_modifiers.bright[item] = true

for ( let item in parsed_modifiers.bright ) {
if ( typeof modifiers.bright[item] === "boolean" ) {
if ( typeof modifiers.bright[item] === 'boolean' ) {
parsed_modifiers.bright[item] = modifiers.bright[item]

@@ -183,5 +332,5 @@ }

if ( Array.isArray( modifiers.decoration ) || ( typeof modifiers.decoration === "object" && modifiers.decoration ) ) {
if ( Array.isArray( modifiers.decoration ) || ( typeof modifiers.decoration === 'object' && modifiers.decoration ) ) {
if ( Array.isArray( modifiers.decoration ) ) {
modifiers.decoration.forEach( function ( item ) {
modifiers.decoration.forEach( ( item ) => {
if ( item in parsed_modifiers.decoration ) {

@@ -193,3 +342,3 @@ parsed_modifiers.decoration[item] = true

for ( let item in parsed_modifiers.decoration ) {
if ( typeof modifiers.decoration[item] === "boolean" ) {
if ( typeof modifiers.decoration[item] === 'boolean' ) {
parsed_modifiers.decoration[item] = modifiers.decoration[item]

@@ -201,20 +350,48 @@ }

if ( reset && ( Array.isArray( modifiers.reset ) || ( typeof modifiers.reset === 'object' && modifiers.reset ) ) ) {
if ( Array.isArray( modifiers.reset ) ) {
modifiers.reset.forEach( ( item ) => {
if ( item in parsed_modifiers.reset ) {
parsed_modifiers.reset[item] = true
}
} )
} else {
for ( let item in parsed_modifiers.reset ) {
if ( typeof modifiers.reset[item] === 'boolean' ) {
parsed_modifiers.reset[item] = modifiers.reset[item]
}
}
}
}
return parsed_modifiers
}
/**
* Writes the timestamp to the logger
*/
function write_timestamp() {
this
.all
.write( "[" )
.fg.bright.black
.write( timestamp( new Date(), this._options.format ) )
.all
.write( "] - " )
.write( '[' )
.write( timestamp( new Date(), this._options.format ), {
fg: 'black',
bright: {
fg: true,
},
} )
.write( '] - ', {
reset: {
all: true
}
} )
}
function set_modifiers() {
let modifiers = this._options.modifiers
if ( !!modifiers.fg ) {
if ( !!modifiers.bright.fg ) {
/**
* Sets the modifiers in the logger
* @param {LoggerDefaultOptions.modifiers|LoggerDefaultOptionsReset.modifiers} modifiers - The modifiers to set
*/
function set_modifiers( modifiers ) {
if ( modifiers.fg ) {
if ( modifiers.bright && modifiers.bright.fg ) {
this.bright

@@ -226,4 +403,4 @@ }

if ( !!modifiers.bg ) {
if ( !!modifiers.bright.bg ) {
if ( modifiers.bg ) {
if ( modifiers.bright && modifiers.bright.bg ) {
this.bright

@@ -237,15 +414,33 @@ }

Object.keys( ansi_codes.modifier ).forEach( function( decoration ) {
if ( !!modifiers.decoration[decoration] ) {
Object.keys( ansi_codes.modifier ).forEach( ( decoration ) => {
if ( modifiers.decoration[decoration] ) {
that.decoration[decoration]
}
} )
if ( modifiers.reset ) {
Object.keys( ansi_codes.reset ).forEach( ( reset ) => {
if ( reset == 'fg' || reset == 'bg' ) {
reset = `reset_${reset}`
}
if ( modifiers.reset[reset] ) {
that.reset[reset]
}
} )
}
}
/**
* Defines a getter method on the Logger
* @param {string} name - The name of the getter
* @param {function} callback - The callback for the getter
* @returns {null}
*/
function define_get( name, callback ) {
if ( name === null || typeof name !== "string" ) {
if ( name === null || typeof name !== 'string' ) {
return
}
if ( callback === null || typeof callback !== "function" ) {
if ( callback === null || typeof callback !== 'function' ) {
return

@@ -255,13 +450,18 @@ }

Object.defineProperty( Logger.prototype, name, {
get: callback
get: callback,
} )
}
/**
* Writes the output to a file
* @async
* @param {string} file - The location to save the file
*/
async function write_file( file ) {
fs.mkdirSync( path.dirname( file ), {
recursive: true
recursive: true,
} )
var file_options = Object.assign( this._options.file_options, {
flag: "a"
const file_options = Object.assign( this._options.file_options, {
flag: 'a',
} )

@@ -272,10 +472,13 @@

["fg", "bg", "modifier", "reset"].forEach( function ( area ) {
var name = area
/**
* Defines the foreground, background, decoration and reset getters
*/
['fg', 'bg', 'modifier', 'reset'].forEach( ( area ) => {
let name = area
if ( name == "modifier" ) {
name = "decoration"
if ( name == 'modifier' ) {
name = 'decoration'
}
define_get( name, function () {
define_get( name, function() {
this._modifier = area

@@ -286,10 +489,14 @@ return this

Object.keys( ansi_codes.fg ).forEach( function ( color ) {
if ( color == "bright" ) {
/**
* Loops through the foreground colors and sets the getters for them
* Sets both foreground & background color getters
*/
Object.keys( ansi_codes.fg ).forEach( ( color ) => {
if ( color == 'bright' ) {
return
}
define_get( color, function () {
if ( this._modifier != "fg" && this._modifier != "bg" ) {
this._modifier = "fg"
define_get( color, function() {
if ( this._modifier != 'fg' && this._modifier != 'bg' ) {
this._modifier = 'fg'
}

@@ -309,14 +516,18 @@

Object.keys( ansi_codes.reset ).forEach( function ( decoration ) {
if ( decoration == "fg" || decoration == "bg" || decoration == "all" ) {
var name = decoration
/**
* Loops through the reset modifiers and sets the getters for them
* Sets both decoration & reset modifier getters
*/
Object.keys( ansi_codes.reset ).forEach( ( decoration ) => {
if ( decoration == 'fg' || decoration == 'bg' || decoration == 'all' ) {
let name = decoration
if ( decoration != "all" ) {
if ( decoration != 'all' ) {
name = `reset_${decoration}`
}
define_get( name, function () {
this._modifier = "reset"
define_get( name, function() {
this._modifier = 'reset'
this.write( ansi_codes[this._modifier][decoration] )
this._modifier = ""
this._modifier = ''
this._bright = false

@@ -328,5 +539,5 @@ return this

define_get( decoration, function () {
if ( this._modifier != "modifier" && this._modifier != "reset" ) {
this._modifier = "modifier"
define_get( decoration, function() {
if ( this._modifier != 'modifier' && this._modifier != 'reset' ) {
this._modifier = 'modifier'
}

@@ -336,4 +547,4 @@

if ( this._modifier == "reset" ) {
this._modifier = ""
if ( this._modifier == 'reset' ) {
this._modifier = ''
this._bright = false

@@ -346,4 +557,5 @@ }

module.exports = exports = function ( options ) {
// eslint-disable-next-line no-multi-assign
module.exports = exports = function( options ) {
return new Logger( options )
}
{
"name": "@stgdp/fancy-logger",
"version": "1.0.0-beta.4",
"version": "1.0.0",
"description": "",

@@ -17,14 +17,35 @@ "license": "MIT",

"scripts": {
"lint": "eslint **/*.js",
"publish": "npm publish --access public",
"test": "mocha"
},
"keywords": [],
"keywords": [
"console",
"log",
"logger",
"logging",
"modifiers",
"decoration"
],
"files": [
"CHANGELOG.md",
"index.js",
"package.json",
"README.md"
],
"engines": {
"node": ">=12"
},
"dependencies": {
"@stgdp/ansi-codes": "1.0.0",
"fecha": "^4.2.0",
"strip-ansi": "^6.0.0"
"fecha": "^4.2.3",
"strip-ansi": "^6.0.1"
},
"devDependencies": {
"mocha": "^8.2.1"
"eslint": "^8.17.0",
"eslint-config-xo": "^0.41.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-unicorn": "^42.0.0",
"mocha": "^10.0.0"
}
}
+145
-50

@@ -5,6 +5,6 @@ # @stgdp/fancy-logger

[![GitHub release](https://img.shields.io/github/v/release/stgdp/fancy-logger?include_prereleases&style=flat-square)](https://github.com/stgdp/fancy-logger/releases/latest)
[![npm Version](https://img.shields.io/npm/v/@stgdp/fancy-logger?style=flat-square)](https://www.npmjs.com/package/@stgdp/fancy-logger)
[![Build Status](https://img.shields.io/travis/com/stgdp/fancy-logger?style=flat-square)](https://travis-ci.com/stgdp/fancy-logger)
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/stgdp/fancy-logger/Linting%20&%20testing?style=flat-square)](https://github.com/stgdp/fancy-logger/actions/workflows/lint-test.yml)
[![License](https://img.shields.io/github/license/stgdp/fancy-logger?style=flat-square)](LICENSE)
[![Dependency Status](https://img.shields.io/david/stgdp/fancy-logger?style=flat-square)](https://david-dm.org/stgdp/fancy-logger)

@@ -30,6 +30,24 @@ `fancy-logger` is a Node.js module that supplies you with a fully-featured console logger to format your terminal. Change the text color, background color, make the text bold, italic, underline and more.

```javascript
const logger = require("@stgdp/fancy-logger");
const logger = require( '@stgdp/fancy-logger' )
// Produces a bold console log with a white background and red text
logger().red.bold.bg.white.write("I'm formatted!").end;
logger()
.red
.bold
.bg
.white
.write( 'I\'m formatted!' )
.end
// OR
logger( {
modifiers: {
fg: 'red',
bg: 'white',
decoration: {
bold: true,
},
},
} )
.write( 'I\'m formatted!' )
.end
```

@@ -56,20 +74,22 @@

// Without options
logger();
logger()
// With options
logger({
logger( {
timestamp: true,
format: "HH:mm:ss",
format: 'HH:mm:ss',
buffer: false,
file: "./logs/node-app.log",
file: './logs/node-app.log',
file_options: {
encoding: "utf8",
encoding: 'utf8',
},
});
} )
```
### write( content: String )
### write( content: String, modifiers: Object )
Outputs provided content to the console through the logger. When the `buffer` option is set to `true`, this will be stored within the logger until either `output` or `return` are called instead.
`modifiers` uses the [Default Modifiers](#default-modifiers) with an additional parameter of `reset` for [reset modifiers](#reset)
#### Usage

@@ -79,3 +99,13 @@

// Outputs "hello world" to the console with a timestamp and new line.
logger().write("hello world").end;
logger()
.write( 'hello world' )
.end
// Outputs "hello world" to the console with a timestamp, new line and blue "world".
logger()
.write( 'hello ' )
.write( 'world', {
fg: 'blue',
} )
.end
```

@@ -90,17 +120,25 @@

```javascript
logger({
file: "./logs/node-app.log",
})
.write("hello world")
.end.to_file();
// Or
logger({
file: path.resolve("./logs/node-app.log"),
})
.write("hello world")
.end.to_file();
// Or
logger().write("hello world").end.to_file("./logs/node-app.log");
// Or
logger().write("hello world").end.to_file(path.resolve("./logs/node-app.log"));
logger( {
file: './logs/node-app.log',
} )
.write( 'hello world' )
.end
.to_file()
// OR
logger( {
file: path.resolve( './logs/node-app.log' ),
} )
.write( 'hello world' )
.end
.to_file()
// OR
logger()
.write( 'hello world' )
.end
.to_file( './logs/node-app.log' )
// OR
logger()
.write( 'hello world' )
.end
.to_file( path.resolve( './logs/node-app.log' ) )
```

@@ -116,3 +154,5 @@

// Outputs "hello world" to the console with a timestamp and new line.
logger().write("hello world").end;
logger()
.write( 'hello world' )
.end
```

@@ -128,3 +168,8 @@

// Outputs "hello world" to the console with a timestamp and new line.
logger({ buffer: true }).write("hello world").end.output;
logger( {
buffer: true,
} )
.write( 'hello world' )
.end
.output
```

@@ -140,3 +185,8 @@

// Returns "hello world"
var msg = logger({ buffer: true }).write("hello world").end.return;
var msg = logger( {
buffer: true,
} )
.write( 'hello world' )
.end
.return
```

@@ -175,10 +225,26 @@

// Sets the logger foreground color to red
logger().red.write("hello world").end;
logger().fg.red.write("hello world").end;
logger()
.red
.write( 'hello world' )
.end
logger()
.fg
.red
.write( 'hello world' )
.end
// Sets the logger background color to red
logger().bg.red.write("hello world").end;
logger()
.bg
.red
.write( 'hello world' )
.end
// Sets the logger background color to bright red
logger().bg.bright.red.write("hello world").end;
logger()
.bg
.bright
.red
.write( 'hello world' )
.end
```

@@ -207,4 +273,11 @@

// Sets the logger decoration to bold
logger().bold.write("hello world").end;
logger().decoration.bold.write("hello world").end;
logger()
.bold
.write( 'hello world' )
.end
logger()
.decoration
.bold
.write( 'hello world' )
.end
```

@@ -236,7 +309,26 @@

// Resets all modifiers
logger().red.bold.write("hello").all.write(" world").end;
logger().red.bold.write("hello").reset.all.write(" world").end;
logger()
.red
.bold
.write( 'hello' )
.all
.write( ' world' ).end
logger()
.red
.bold
.write( 'hello')
.reset
.all
.write(' world')
.end
// Resets the bold modifier, leaving the foreground modifier alone
logger().red.bold.write("hello").reset.bold.write(" world").end;
logger()
.red
.bold
.write( 'hello')
.reset
.bold
.write(' world')
.end
```

@@ -252,6 +344,6 @@

// Output will have a bright red foreground, blue background and be bold
logger({
logger( {
modifiers: {
fg: "red",
bg: "blue",
fg: 'red',
bg: 'blue',
bright: {

@@ -274,13 +366,16 @@ fg: true,

},
}).write("hello world").end;
} )
.write( 'hello world' )
.end
// OR
// Output will have a bright red foreground, blue background and be bold
logger({
logger( {
modifiers: {
fg: "red",
bg: "blue",
bright: ["fg"],
decoration: ["bold"],
fg: 'red',
bg: 'blue',
bright: ['fg'],
decoration: ['bold'],
},
}).write("hello world").end;
} )
.write( 'hello world' )
.end
```

@@ -287,0 +382,0 @@