orange-soda
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

Orange Soda

Installation

npm i orange-soda -s

Basic Usage

Leveled Logging

// import the library
const {logger} = require('../dist/index');
 
// this are leveled log functions
// first the level needs to be set
 
logger.level = 'debug';
 
// this means that only levels higher than or equal to debug will be logged
// these for example will be logged...
logger.warn('This is a %s message', 'warn');
logger.debug('This is a %s message', 'debug');
 
// but this will not...
logger.verbose('This is a %s message', 'verbose');
 
// the format in which the log messages is output can also be changed like so...
logger.format = 'detailed';
 
// this will make the leveled logs look diffrent
logger.debug('This is a %s message', 'debug');

Access Logging

// import the library
const {logger} = require('../dist/index');
 
// import a http router library like express or connect
const express = require('express');
let app = express();
 
// setup the access logger...
logger.access.format = 'common';
 
// set the router to use the logging middleware...
app.use(logger.access.middleware());
 
// handle your requests...
app.use('/', (req, res) => {
  res.send('<h1>Hello World</h1>');
});
 
// listen for requests...
app.listen(3000);

Logging Groups

Logging groups are collections of logging methods that all have a similar function. The two default logging groups are the leveled group and access group. The leveled group handles any logs that can be leveled. The access group handles logs that pertain to the access of something. For example, the access of a server. Read more on log groups here.

Transports

Transports are like write streams, but they also know how to format log data according to the transport's settings. The default transports are the console and file transports. The console transport writes to standard out and standard error. The file transport writes to the specified file. Read more on transports here

Docs

More detailed documentation can be found here.

License

MIT License

Readme

Keywords

none

Package Sidebar

Install

npm i orange-soda

Weekly Downloads

0

Version

1.0.3

License

MIT

Last publish

Collaborators

  • stormymcstorm