All Projects → eggjs → Egg Logger

eggjs / Egg Logger

Licence: mit
Egg logger

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Egg Logger

Nuxt Egg
Nuxt.js + Egg FrameWork
Stars: ✭ 86 (-32.28%)
Mutual labels:  egg
Sniffer
Networking activity logger for Swift
Stars: ✭ 108 (-14.96%)
Mutual labels:  logger
Egg Router Plus
The missing router feature for eggjs
Stars: ✭ 117 (-7.87%)
Mutual labels:  egg
Egg Vue Webpack Boilerplate
Egg Vue Server Side Render (SSR) / Client Side Render (CSR)
Stars: ✭ 1,302 (+925.2%)
Mutual labels:  egg
Egg Passport
passport plugin for egg
Stars: ✭ 98 (-22.83%)
Mutual labels:  egg
Blog
天猪部落阁 http://atian25.github.io
Stars: ✭ 1,527 (+1102.36%)
Mutual labels:  egg
Project
⭐️ Antares Project Application Skeleton. This is the very first place you should start. It allows you to create a brand new awesome project in easy few steps.
Stars: ✭ 84 (-33.86%)
Mutual labels:  logger
Docker Logger
Logs collector for docker
Stars: ✭ 126 (-0.79%)
Mutual labels:  logger
Speedtest Linux
Get download/upload speeds via speedtest.net or fast.com from command line using Bash script -- suitable for logs. POSIX OSX Linux
Stars: ✭ 103 (-18.9%)
Mutual labels:  logger
Serverlog
A simple, practical and innovative Node.js log library that enables you to view logs in Chrome dev tools and browser Console.
Stars: ✭ 117 (-7.87%)
Mutual labels:  logger
Superlogger
Save NSLog() to file and send email to developer
Stars: ✭ 93 (-26.77%)
Mutual labels:  logger
Logsip
A simple, concise, colorful logger for Go
Stars: ✭ 94 (-25.98%)
Mutual labels:  logger
Node Lambda Log
Basic logging mechanism for Node 6.10+ Lambda Functions
Stars: ✭ 115 (-9.45%)
Mutual labels:  logger
React Native Logs
Performance-aware simple logger for React-Native with namespaces, custom levels and custom transports (colored console, file writing, etc.)
Stars: ✭ 84 (-33.86%)
Mutual labels:  logger
Logback Access Spring Boot Starter
Spring Boot Starter for Logback-access
Stars: ✭ 118 (-7.09%)
Mutual labels:  logger
Rain
Visualize vertical data inside your terminal 💦
Stars: ✭ 84 (-33.86%)
Mutual labels:  logger
Egg Cnode
CNode 社区 Egg 版本
Stars: ✭ 1,456 (+1046.46%)
Mutual labels:  egg
Examples
Store all egg examples in one place
Stars: ✭ 1,668 (+1213.39%)
Mutual labels:  egg
Plug logger json
Elixir Plug that formats http request logs as json
Stars: ✭ 125 (-1.57%)
Mutual labels:  logger
Silencer
Easily suppress the Rails logger
Stars: ✭ 116 (-8.66%)
Mutual labels:  logger

egg-logger

NPM version build status Test coverage Known Vulnerabilities npm download

Egg logger.

diagram

Including two base class, Logger and Transport:

  • Transport: Save log to file, stdout/stderr and network.
  • Logger: A logger can contains multi transports.

Install

$ npm i egg-logger

Usage

Create a Logger and add a file Transport.

const Logger = require('egg-logger').Logger;
const FileTransport = require('egg-logger').FileTransport;
const ConsoleTransport = require('egg-logger').ConsoleTransport;

const logger = new Logger();
logger.set('file', new FileTransport({
  file: '/path/to/file',
  level: 'INFO',
}));
logger.set('console', new ConsoleTransport({
  level: 'DEBUG',
}));
logger.debug('debug foo'); // only output to stdout
logger.info('info foo');
logger.warn('warn foo');
logger.error(new Error('error foo'));

Enable / Disable Transport

logger.disable('file');
logger.info('info'); // output nothing
logger.enable('file');
logger.info('info'); // output 'info' string

Duplicate

Duplicate error log to other logger.

Accept an options.excludes to special whether excludes some tranports.

logger.duplicate('error', errorLogger, { excludes: [ 'console' ]});
logger.error(new Error('print to errorLogger')); // will additional call `errorLogger.error`

Redirect

Redirect special level log to other logger.

oneLogger.redirect('debug', debugLogger); // all debug level logs of `oneLogger` will delegate to debugLogger

Reload

logger.reload(); // will close the exists write stream and create a new one.

Custom Transport

You can make your own Transport for logging,e.g.: send log to your logging server.

const urllib = require('urllib');
const Transport = require('egg-logger').Transport;

class UrllibTransport extends Transport {

  log(level, args, meta) {
    const msg = super.log(level, args, meta);
    return urllib.request('url?msg=' + msg);
  }
}

const logger = new Logger();
logger.set('remote', new UrllibTransport({
  level: 'DEBUG',
}));
logger.info('info');

Console logger level

set environment NODE_CONSOLE_LOGGRE_LEVEL = 'INFO' | 'WARN' | 'ERROR'

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].