qm-state

0.1.2 • Public • Published

qm-state

npm version Build Status

State object for my js scripts (qm-state) with implementation of winston logger and debug option.

Installation

$ npm i -S qm-state

Usage

const { createState }  = require('qm-state');
 
const state = createState(options);

Configuration

Default options object:

{   
    addAppMethods = {},
    debug = false,
    includeLogger = false,
    loggerFileName = '.logs.log',
    loggerOptions = {},
    loggerFileOptions = {}
}

addAppMethods

Object with references to app methods.

debug

When true state logs all message levels to file.

includeLogger

When true includes winston logger to the state.

loggerFileName

Define file name for logger (when debug option set true).

loggerOptions

Winston default logger options:

{    
  newLogFilePerInstance: true,
  addTimeStamp: true,
  timeStampType: 'd-compact',
    // d- defoult long compact compressed old
    // t- defoult ordinary long compressed
  formatterType: 'service',
  colorize: false,
  maxsize: null,
  maxFiles: null,
  zippedArchive: false,
  level: 'silly',
  json: false
}

loggerFileOptions

Default file transport options for winston logger (when debug option set true):

{
    addTimeStamp: true,
    timeStampType: 'd-compact',
      // d- defoult long compact compressed old
      // t- defoult ordinary long compressed
    formatterType: 'service', // service |
    colorize: false,
    level: 'silly'
}

API

state.returnAPI(result)

Returns new object with results of the app.

{result, state, logs }

state.addOptions(options)

Adds options object to the state.

Credits

License

MIT © qaraluch

Readme

Keywords

none

Package Sidebar

Install

npm i qm-state

Weekly Downloads

1

Version

0.1.2

License

MIT

Last publish

Collaborators

  • qaraluch