@turnkeyid/sexy-logger
v1.0.13
Published
ready to use logger with file rotation
Downloads
3
Readme
Welcome to TurnkeyID Sexy Logger! 💌 👋
Simple pretty logger console and save logs into file daily (with error/exception handler)
Goal
- Services can get their own, standarized and pretty system logger.
- Services can call simple logger function anywhere
- Logs all important message and save it into seperated logger file for easy debuging
How to use
- install this package
npm install --save @turnkeyid/sexy-logger # or yarn add @turnkeyid/sexy-logger
- create your own logger function:
// ./helpers/my-logger.ts import { LoggerServiceFactory } from '@turnkeyid/sexy-logger' import path from 'path' const MyLoggerService = LoggerServiceFactory.createLoggerService({ consoleSilent: false, consoleMode: 'VERBOSE', consoleShowDump: true, consoleIgnoredLevels: ['SILLY'], censoredKeys: ['cencored','password'], loggerDir: path.resolve(__dirname,'logs'), }) export const myLogger = MyLoggerService.createLoggerFn('MY-TYPE')
- import it somewhere:
// ./index.ts import {myLogger} from './helpers/my-logger.ts' myLogger(module,'title',{ data:{ any:'data' } },'SILLY') myLogger(module,'error title',{ error:new Error('caught error') },'ERROR') someAsync = async()=>{ // do something } someAsync().then((data)=>{ myLogger(module,'success!',{ data },'INFO') }).catch((error)=>{ myLogger(module,'error!',{ error },'ERROR') })
- if you got
"cannot create logger instance"
, try to setprocess.env.SEXY_LOGGER_MAX_INSTANCE=
higher than current value.
Preview Sample
Author
👷♀️ TurnkeyID Developers - Fatihaziz
- Website: turnkey.id
- Github: @turnkey-devs
- Fatih's Github: @fatihaziz
Question
Show your support
Give a ⭐️ if this project helped you!