Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jetlog

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jetlog

Streamet logger with pluggable outputs and stream interface.

  • 1.0.54
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
21
increased by61.54%
Maintainers
1
Weekly downloads
 
Created
Source

JetLog

Streamed logger with multiple simltaneous output options.

The intention of this module is to allow pushing the log data to an API, some file and still be able to see the data in stdout.

Streams are based on scramjet so you can use any transforms you like on your streams.

Default output

No colors, no fancy line drawing, nothing yet really - just a simple and parsable log output...

2018-06-29T15:07:37.339Z jetlog [info] defaultOutput(simple.js:52) Message1
2018-06-29T15:07:37.339Z jetlog [log] defaultOutput(simple.js:53) Message2
2018-06-29T15:07:37.339Z jetlog [error] defaultOutput(simple.js:54) Message3!

Usage

Simple version:

const logger = require('jetlog');
jetlog.log("Some message", {some_extra: data});

More complex version:

const {JetLog, Entry} = require('jetlog');

const logger = new JetLog({})
    .catch(e => new Entry("Invalid log entry", e)); // remember to handle errors

logger
    .use("my-decorator-module") // use stream modules to add data to logs
    .toJSONStream() // use `scramjet` transforms to do anything you like to your logs
    .tee(fs.createWriteStream("/var/log/myapp.log")) // push log to file

logger
    .filter(({level}) => level >= 3) // use scramjet functions on entries
    .stringify(myParser) // stringify your log
    .pipe(process.stdout); // pipe anywhere you like

logger
    .level("warn") // level will be assigned to the chained method
    .use("my-reporter") // you can use own reporters
    .pipe(process.stderr);

Environment control

Jetlog's default logger (the one exposed as module.exports) behavior can be changed using the following environment variables:

  • JETLOG_REPORTER - choose reporter module "./lib/entry-reporter" by default.
  • JETLOG - boolean - set to "0" to disable stdout.
  • JETLOG_FILTER - only log if Entry matches any of the words (space separated).

API

  • module.exports : JetLog - the default export is a JetLog instance piped to stdout using the standard log reporter.
  • module.exports.getLog(name, pipeToOutput, reporter, filterArray) - a facilitation method for creating loggers
  • module.exports.JetLog - the main logger class is exported

JetLog class

JetLog class implements the following methods:

Logging methods are as follows in the following order:

JetLog Entries

Each log message is turned to a stream object.

Props:

See more about Entry here

License

JetLog is MIT licensed.

Keywords

FAQs

Package last updated on 24 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc