1.3.0 • Published 5 years ago

@tne/logger v1.3.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

@tne/logger

A basic logger for Node.js applications, completely written with typescript, is not only the basic logger for the entire @tne platform, since being completely decoupled from tne is free to use for any other application Node.js

Menu

Installation

@tne/logger

interfaces


Back to Menu

Installation

You can install through the node package managers:

NPM

$ npm i -S @tne/logger

Yarn

$ yarn add @tne/logger

Back to Menu

@tne/logger

@tne/logger is the main library which is responsible for making 'winston' coverage and standardizing the use for @tne. @tne/logger

Example basic usage

just create an instance without providing arguments

import { TneLogger } from '@tne/logger';

// create a simple console logger
const logger = new TneLogger;

logger.info('hello!')	// outputs-> [timestamp] info: hello!
logger.info('message 1537574380254');	// outputs -> [timestamp] info: message 1537574380254
logger.warn('message 1537574380254');	// outputs -> [timestamp] warn: message 1537574380254
logger.error('message 1537574380254');	// outputs -> [timestamp] error: message 1537574380254

Example usage with file logger

provide a config object that implements the ISettings interface

import { TneLogger } from '@tne/logger';

// ISettings
const config = {
	fileCfg: {
		logsPath: process.pwd() + '/logs',
		logFile: 'someFileName',
	}
};


// create a console logger with file persistence
const logger = new TneLogger(config);

logger.info('hello!')	// outputs-> [timestamp] info: hello!
logger.info('message 1537574380254');	// outputs -> [timestamp] info: message 1537574380254
logger.warn('message 1537574380254');	// outputs -> [timestamp] warn: message 1537574380254
logger.error('message 1537574380254');	// outputs -> [timestamp] error: message 1537574380254

The above code will also dump logs to a several logs files placed on path specified by logsPath argument.


Back to Menu

Interfaces

The interfaces that this library provides and that are described here provide help to the developer that will consume this library to build incredible web applications.

Constraints

The interfaces mentioned in this section will be importable only if you are developing your web application with typescript.


Back to Menu

ISettings

Used as a constructor argument for TneLogger class.

Parameters

ParamTypeRequired?Description
levelstringfalsewinston logging level
fileCfgIFileSettingsfalseIFileSettings object
customTransportsTransport[]falseA custom winston-transport Array.

IFileSettings Back to Menu

IFileSettings

Used as a nested config on constructor argument for TneLogger class.

When you provide this config object a log file will be created per day.

Parameters

ParamTypeRequired?Description
logsPathstringtruevalid path where TneLogger will create the log files.
logFilestringfalsefilename for the further log files default: 'log.log'
datePatternstringfalsedata pattern for the further log files default: 'YYYMMDD'

Back to Menu

1.3.0

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.2

6 years ago

1.0.1-beta

6 years ago

1.0.0

6 years ago