1.0.3 • Published 6 years ago

green-jay v1.0.3

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

Green-Jay

A Javascript Logger.

Installing

$ npm install green-jay

Usage

// parameters are optional.
// without options, logger will just log on console.
greenjay.createLogger({
    outputType: 'json',
    modifiers: {
        date:{
            color: '#069'
        },
        message: {
            modify: 'underline'
        }
    },
    logs: [
        new greenjay.logger({
            filePath: './logs/errors.log',
            minLevel: 'error'
        })
    ]
});

Logging

All functions

    greenjay.emergency('Some Emergency');
    greenjay.alert('Some Alert');
    greenjay.critical('Some Critical');
    greenjay.error('Some Error');
    greenjay.warning('Some Warning');
    greenjay.info('Some Info');
    greenjay.debug('Some Debug');
    greenjay.trivial('Some Trivial');

Labels

// can give a label to it too..
greenjay.alert('PANIC!!', 'remember to panic.');

Levels


From the most important to least.

LevelName
1Emergency
2Alert
3Critical
4Error
5Warning
6Info
7Debug
8Trivial

Options, Modifiers and Logs


Options

NameTypeDefaultDescription
useConsolebooleantrueDefines Should Logger Prints to Console.
outputTypestringtextDefines Output Type. - 'text' or 'json'
defaultLevelColorsbooleantrueDisables/Enables Default Level Colors Default Colors of Levels
stopProgramAbovestringDoes Not Stop ProgramStops Program If Selected Level and Above Occurs.
modifyobjectDefault Settings.more info about modify
logsobjectNo Log Writing to File.more info about logs

Modifiers

NameTypeDefault
dateobjectempty
date colorstringwhite
date modifystringnothing
date bgstringnothing
messageobjectempty
message colorstringwhite
message modifystringnothing
message bgstringnothing
levelobjectempty
level colorstringwhite
level modifystringnothing
level bgstringnothing

Logs

NameTypeDefaultDescription
filePathstringno defaultPath to Log File. If Includes Folder Path, It Will Create If It Doesn't Exist.
minLevelstringno defaultLogs Entered Minimum Level and Above of It.

Colors


Valid Color Keywords

Accepts Hex and RGB values

    #abc426
    (150,123,77)

Color Names for Text Color or Background Color.

  • black
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white
  • gray
  • redbright
  • greenbright
  • yellowbright
  • bluebright
  • magentabright
  • cyanbright
  • whitebright

Default Level Colors

LevelNameDefault Color
1Emergency#e0f795
2Alert#ef9c24
3Critical#ef4824
4Error#ef2424
5Warning#efb424
6Info#2f89f5
7Debug#34ed72
8Trivial#ffffff

Valid Modifiers


  • bold
  • underline

Stoping Program


You can stop program if given level and above logging occurs.

Example :

options.stopProgramAbove = 'error'

if emergency or critical or error logging happens logger will log it and closes the program.

Licence

MIT

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.1

6 years ago