Skip to content

lemoncloud-io/lemon-logger-lib

Repository files navigation

lemon-logger-lib

Build Status

TypeScript console logger for LemonCloud

Install

$ npm install @lemoncloud/lemon-logger-lib

Usage

default

import { Logger } from '@lemoncloud/lemon-logger-lib';

const logger = new Logger('LEMON');
const logger2 = new Logger('LEMON2', { showTimestamp: false, showLogType: false });

logger.log('this is log', 'extra params: ', { type: 'debug'}); 
logger.debug('this is debug', 'extra params: ', { type: 'debug'});

logger2.info('this is info', 'extra params: ', { type: 'info'});
logger2.warn('this is warn', 'extra params: ', { type: 'warn'});
logger2.error('this is error', 'extra params: ', { type: 'error'}, 'test');

http

const logger = new Logger('LEMON', {
    shouldSend: true,
    httpHost: 'http://localhost:8333',
    httpMethod: 'POST',
    httpPath: '/mock/log',
});

socket

const logger = new Logger('LEMON', {
    useSocket: true,
    socketHost: 'http://localhost:5555',
    socketEvent: 'LOG',
});

Options

Logger([namespace], [options])

showTimestamp

Type: boolean
Default: true

showLogType

Type: boolean
Default: true

shouldSend

Type: boolean
Default: false

httpHost

Type: string
Default: ''

httpMethod

Type: string
Default: ''

httpPath

Type: string
Default: ''

useSocket

Type: boolean
Default: false

socketHost

Type: string
Default: ''

socketEvent

Type: string
Default: ''

Methods

logger.log('test message')

logger.debug('test message')

logger.info('test message')

logger.warn('test message')

logger.error('test message')

logger.setOptions({ shouldSend: false })

logger.closeSocket()

Sample

A quick sample is provided as example.js

About

Common logger for browser

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •