A personal console logger for my node.js APIs.
npm install my-own-log
ou :
npm i -S my-own-log
const log = require('my-own-log')
log({
name: 'Express',
status: 'reg',
value: 'is connected on port 3000 !',
mode: 'dev'
})
name
: name of the application which is talkingstatus
:
status | description | icon |
---|---|---|
reg |
regular | ✔️ |
ok |
success | ✔️ |
warn |
warning | |
err |
error | ❌ |
wait |
waiting | ⌛ |
info |
info | ❕ |
value
: message to log (you can send emoji with github codes:name_of_the_emoji:
)mode
:dev
: developmentprod
: production
showTime
: show dateTimeclear
: clear console before logging
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.
parameter | type | default value | description | possible values |
---|---|---|---|---|
showTime | boolean | false |
log the date time before all | true , false |
setTime | string | 'HH mm ss' |
set the format of the time | all kind of format that moment.js accepts (ISO 8601) |
clearOnce | boolean | true |
clear console on the first log | true , false |
clear | boolean | false |
clear console on every log | true , 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' })
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!
- Trigger Time : Set a trigger time (for example minute), to show time only if the last log was displayed more than a minute ago