1.0.1 • Published 1 year ago
@rathfi/logger v1.0.1
@rathfi/logger
logger used by rath finance
Installation
npm install @rathfi/loggerUsage
import { Logger } from '@rathfi/logger';
const logger = new Logger();
// Set log level (optional, defaults to INFO)
logger.setLogLevel('DEBUG');
function myFunction() {
// Basic logging
logger.info({ 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:
// info_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)
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