2.0.2 • Published 3 years ago

@nedbot/logger v2.0.2

Weekly downloads
6
License
Apache-2.0
Repository
github
Last release
3 years ago

@nedbot/logger

NedBot logger is a configuration wrapper for the Winston logger.

Installation

Yarn:

yarn add @nedbot/logger

NPM:

npm i @nedbot/logger

Configuration

import { Logger } from "@nedbot/logger";

const logger = new Logger({
  logFilesDirectory: "logs",
  mainLogFileName: "info",
  errorLogFileName: "error",
  timestampFormat: "DD/MM/YYYY @ HH:mm:ss",
  enableConsoleLogs: true,
  enableMainLogFile: true,
  enableErrorLogFile: true,
  fileDateFormat: "DD-MM-HH-YYYY",
  zippedArchive: true,
  maxSize: "2m",
  maxFiles: "14d",
  source: "NedBot",
  colors: {
    error: "red"
  }
});

LoggerOptions

OptionTypeDefaultDescription
logFilesDirectorystringlogsThe path to the directory that will hold log files.
mainLogFileNamestringinfoThe name of the main log file.
errorLogFileNamestringerrorThe name of the error log file.
timestampFormatstringDD/MM/YYYY @ HH:mm:ssThe format of the log timestamps.
enableConsoleLogsbooleantrueWhether or not to enable console logs.
enableMainLogFilebooleanfalseWhether or not to enable main file logs.
enableErrorLogFilebooleanfalseWhether or not to enable error file logs.
fileDateFormatstringDD-MM-HH-YYYYThe date format for the log files.
zippedArchivebooleantrueWhether or not to gzip archived log files.
maxSizestring2mThe maximum log file size. Specify the size, and the unit. Size is a number, unit is either k (for kb), m (for mb) or g (for gb). Example: 50m
maxFilesstring | number14dThe maximum count of saved log files. Use a number for file count, or a number suffixed by "d" for the amount of log file days to keep.
sourcestringThe logger source. If specified, this will be printed in the logs (helpful for knowing which logger printed a log entry).
colorsLoggerColors{}An object mapping each log level and console logger components to a color.