Git Product home page Git Product logo

oylog's Introduction

oy-log

Log text to screen, file or both. Uses simple semantic syntax

oy-log allows you to log messages and errors to screen and/or files

Installation

$ npm install oy-log

Usage

All features snippet:

// Init
var oylog = require('oy-log');
var log = new oylog();

// Config (optional)
log.config.appName = 'my-app'; // Will be displayed for each message
log.config.logFile = './app.log'; // Hold log messages
log.config.errorLogFile = './error.log'; // Hold error messages

// Money Time
log.start(); // put current date snapshot into log files

log.message.to.screen ('Hey, i\'m a message'); 
log.message.to.screen ('Action', 'I just did something');
log.message.to.file ('This message is shown only in app.log');
log.message.to.file ('Saved', 'A file has been saved');
log.message.to.both ('Action', 'This one will appear in both, file and screen');

log.error.to.screen ('Something went wrong...'); 
log.error.to.screen ('This is what went wrong: ', 'Capitalism');
log.error.to.file ('This error is shown only in error.log');
log.error.to.file ('Can\'t save file', 'something.json');
log.error.to.both ('Can\'t connect: ', 'Inner soul');

log.end(); // Will generate the log files 

Result on screen:
alt text

app.log:

Mon Apr 11 2016 11:24:56 GMT+0300 (Jerusalem Daylight Time)


[11:24:56] my-app: This message is shown only in app.log
[11:24:56] my-app: Saved: A file has been saved
[11:24:56] my-app: Action: This one will appear in both, file and screen


Total Run Time: 30ms

error.log:

Mon Apr 11 2016 11:24:56 GMT+0300 (Jerusalem Daylight Time)


[11:24:56] ERROR my-app: This error is shown only in error.log
[11:24:56] ERROR my-app: Can't save file: something.json
[11:24:56] ERROR my-app: Can't connect: : Inner soul


Total Run Time: 30ms

oylog's People

Contributors

royhersh avatar

Stargazers

 avatar Marcelo Fernandes 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.