2.1.2 • Published 6 years ago

au5ton-logger v2.1.2

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

logger

console.log() is too boring for me, so I wrote an npm module that hijacks it.

FOSSA Status

Installation:

  1. Run: npm install au5ton-logger
  2. Add the following code:
require('au5ton-logger')();

// or with some options (only initialize it once)

require('au5ton-logger')({
    emoji: true, // uses emoji in print messages
    prefix_date: false, // prefixes with [YYYY/MM/DD @ HH:MM:SS]
    tab_size: 4, // amount of spaces to use when console.ind() is called
});

Example code

require('./logger')()

// Different styles of prints
console.log('A normal log function')
console.info('I have some important information for you!')
console.warn('This might be a problem later.')
console.error('Houston, we have a problem.')
console.success('Great job!')
console.flag('Lets diagnose what went wrong here')

// Easy Identation
console.log('normal');
console.ind().log('indented once');
console.ind(2).log('indented twice');

// Chalk integration
let chalk = console.chalk
console.log(chalk.magenta('I am magenta!'))

let methods=['bold','dim','italic','underline','inverse','strikethrough','black','red','green','yellow','blue','magenta','cyan','white','gray','redBright','greenBright','yellowBright','blueBright','magentaBright','cyanBright','whiteBright','bgBlack','bgRed','bgGreen','bgYellow','bgBlue','bgMagenta','bgCyan','bgWhite','bgBlackBright','bgRedBright','bgGreenBright','bgYellowBright','bgBlueBright','bgMagentaBright','bgCyanBright','bgWhiteBright'];
for(let i in methods) {
    // Calls every console.<modifier> function. Example: console.bold, console.cyan
    console[methods[i]]('Styles!')
}

Result

example.png

API

console.info(args)

same as built-in console.info, but all text is bold and the line starts with :grey_exclamation:

console.warn(args)

same as built-in console.warn, but all text is yellow and the line starts with :warning:

console.error(args)

same as built-in console.error, but all text is red and the line starts with :no_entry_sign:

console.success(args)

same as console.log, but all text is green and the line starts with :white_check_mark:

console.flag(args)

prints the arguments and a stack trace in red

console.ind(n)

Prints ' ' options.tab_size * n times, returns console to allow chaining

console.nl(n)

Prints '\n' n times

console.chalk

A chalk instance.

console.<chalk_function>

Prints a shortcut to a chalk function. For example, console.blue('hello') equals console.log(chalk.blue('hello'))

For valid methods, see logger.js

License

FOSSA Status

2.1.2

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.3.4

7 years ago

1.3.3

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.2

8 years ago

1.1.1

8 years ago