1.0.9 • Published 3 years ago

@zzck.dev/logger v1.0.9

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Yet another Logger

Features:

  1. Embedded highlightning
  2. Easy to use
  3. Not async (for now)
  4. Easily can be created as many loggers as you want with different settings
  5. Can be setup using config file (in progress)
  6. TS compatible

Get started

Simple usage

import { GetLogger } from "@zzck.dev/logger";

const mainLogger = GetLogger("main")

mainLogger.info('Info message')
mainLogger.warn('Warn message')
mainLogger.log('Log message')
mainLogger.error('Error message')
mainLogger.debug('DebugDisabled message')
/* By default debug is disabled */
mainLogger.config.debugEnabled = true
mainLogger.debug('DebugEnabled message')

Output: Simple usage output

Logger configuration

import { GetLogger } from "@zzck.dev/logger";

const configExample = GetLogger('ConfigExample')
configExample.config = {
    name: "AnotherConfigExample",
    infoEnabled: false,
    logEnabled: false,
    debugEnabled: true,
    delim: '@'
}

configExample.info('Info message')
configExample.warn('Warn message')
configExample.log('Log message')
configExample.error('Error message')
configExample.debug('Debug message')

Output: Simple config

Advanced usage

Internally GetLogger creates a singleton instance of LoggerManager which after spawns loggers. Following logic is incapsulated in GetLogger function:

let _manager = null

function GetLogger(name: string): ConsoleLogger {
    if (_manager == null) _manager = new ConsoleLoggerManager()
    return _manager.Get(name)
}

So if you want to control the lifetime of logger manager object you can create it by yourself, as on the following example:

import { ConsoleLoggerManager } from "@zzck.dev/logger";

const manager = new ConsoleLoggerManager()
const logger = manager.Get("logger")

logger.error("2+2=5")

Output: LoggerManager created by yourself

1.0.2

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago