GithubHelp home page GithubHelp logo

hartl3y94 / winston-array-transport Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pustovitdmytro/winston-array-transport

0.0 0.0 0.0 279 KB

write winston logs directly to javascript Array

License: MIT License

JavaScript 97.46% Shell 2.54%

winston-array-transport's Introduction

winston-array-transport

winston-array-transport write winston logs directly to javascript Array.

Version Dependencies Vulnerabilities Build Status Coverage Status License

Table of Contents

Motivation

There are a lot of cases, where you need to parse and analyze your logs. For example to access them during tests. This package provides transport, that allows simply push logs to js array, so you don't need any runtime parsers anymore.

Requirements

To use library you need to have node and npm installed in your machine:

  • node 6.0+
  • npm 3.0+

Installation

To install the library run following command

  npm i --save winston-array-transport

Usage

The package can be used alongside any other winston transport.

import ArrayTransport from 'winston-array-transport';
import { createLogger } from 'winston';

const logs = [];
const transport  = new ArrayTransport({ array: logs, json: true, level: 'info' });

export const logger = createLogger({
    transports : [ transport ]
});

Configuration

Next options can be configured while transport creation:

  • name - name of a transport, ArrayTransport by default;
  • eol - end of line , os.EOL by default;
  • array - array, where all logs will be stored;
  • parser - function, that will be applied to log messages;
  • json - if set to true, JSON.parse parser will be used;
  • limit - allows to limit amount of logs to n last items;

Contribute

Make the changes to the code and tests and then commit to your branch. Be sure to follow the commit message conventions.

Commit message summaries must follow this basic format:

  Tag: Message (fixes #1234)

The Tag is one of the following:

  • Fix - for a bug fix.
  • Update - for a backwards-compatible enhancement.
  • Breaking - for a backwards-incompatible enhancement.
  • Docs - changes to documentation only.
  • Build - changes to build process only.
  • New - implemented a new feature.
  • Upgrade - for a dependency upgrade.
  • Chore - for tests, refactor, style, etc.

The message summary should be a one-sentence description of the change. The issue number should be mentioned at the end.

winston-array-transport's People

Contributors

pustovitdmytro avatar semantic-release-bot 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.