Git Product home page Git Product logo

logger's Introduction

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:
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: 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.

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' })

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

logger's People

Contributors

seba1204 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.