Skip to content

RathFinance/logger

Repository files navigation

@rathfi/logger

logger used by rath finance

Installation

npm install @rathfi/logger

Usage

import { Logger } from '@rathfi/logger';

const logger = new Logger();

// Set log level (optional, defaults to INFO)
logger.setLogLevel('LOG');

function myFunction() {
  // Basic logging
  logger.log({ Id: '123', message: 'Processing started' });
  
  try {
    // ... your code ...
    logger.debug({ Id: '123', status: 'success' });
  } catch (error) {
    logger.error({ Id: '123', error: error.message });
  }
}

// Output format examples:
// myFunction(id=123,message=Processing started)
// debug_myFunction(id=123,status=success)
// error_myFunction(id=123,error=Something went wrong)

Log Levels

Available log levels (in order of priority):

  • FATAL (0)
  • ERROR (1)
  • WARN (2)
  • INFO (3) - default
  • DEBUG (4)
  • LOG (5) - regular logging

API

logger.setLogLevel(level)

Set the minimum log level. Messages below this level will not be logged.

Logging Methods

  • logger.fatal(params)
  • logger.error(params)
  • logger.warn(params)
  • logger.info(params)
  • logger.debug(params)
  • logger.log(params) (alias for regular logging)

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published