0.2.0 • Published 5 years ago

my-own-log v0.2.0

Weekly downloads
6
License
ISC
Repository
github
Last release
5 years ago

logger

A personal console logger for my node.js APIs.

Install

npm install my-own-log

ou :

npm i -S my-own-log

Usage

const log = require('my-own-log')
log({
  name: 'Express',
  status: 'reg',
  value: 'is connected on port 3000 !',
  mode: 'dev'
})

Parameters

  • name: name of the application which is talking
  • status:
statusdescriptionicon
regregular✔️
oksuccess✔️
warnwarning⚠️
errerror
waitwaiting
infoinfo
  • value: message to log (you can send emoji with github codes :name_of_the_emoji:)
  • mode:
    • dev: development
    • prod: production
  • showTime: show dateTime
  • clear: clear console before logging

Global settings

You can setup some global settings that will be saved as long as yout node.js server live, so it will be applied to all your lgos. You have to execture this commands before any logging.

parametertypedefault valuedescriptionpossible values
showTimebooleanfalselog the date time before alltrue, false
setTimestring'HH mm ss'set the format of the timeall kind of format that moment.js accepts (ISO 8601)
clearOncebooleantrueclear console on the first logtrue, false
clearbooleanfalseclear console on every logtrue, false

For example (in es6), if your main file is index.js:

// index.js
import log, { settings as setLog } from 'my-own-log'

// Show time on every log
setLog.showTime = true

// clear console on the first log
setLog.clearOnce = true

// Display milliseconds
setLog.setTime = 'HH mm ss SS'

// Log something
log({ name: 'Server', value: 'yes', status: 'ok' })

Example

const log = require('my-own-log')
log({
  name: 'Express',
  status: 'ok',
  value: 'is connected :link: on port 3000!'
})

output:

✔️ [Express] is connected 🔗 on port 3000!

Todo

  • Trigger Time : Set a trigger time (for example minute), to show time only if the last log was displayed more than a minute ago
0.2.0

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago