An opinionated file logger with limited rotation policy options, base on pino.
this package provides:
- quick start with default configuration.
- an instance of pino logger.
- flexibility of pino with options and prettify the output.
- create log files in
logs
directory of root project directory. - delete old log files.
- type safe with typescript.
This is an opinionated package that limit the flexibility of awesome pino package. if you need full functionality please use original package.
import { createLogger } from "fast-node-logger";
const logger = await createLogger();
logger.info(`Logger is Ready!`);
You can use the complimentary extension for VSCode writelog-snippets.
const options: Options = {
logDir: "./my-logs",
retentionTime: 604800, // for 7 days
};
await createLogger(options);
use pino original options Pino Docs
import { createLogger, Options } from "fast-node-logger";
const options: Options = {
level: "trace",
};
const logger = await createLogger(options);
returns an instance of pino
import { createLogger } from "fast-node-logger";
const logger = await createLogger();
logger.info(`Logger is Ready!`);
a shortcut for logger.info(message)
with ability to additionally print to console with second parameter {stdout: true}
import { writeLog, createLogger, Options } from "fast-node-logger";
await createLogger();
writeLog(`logger is created!`, { stdout: true, level: "trace" });
- add recommended log rotation
- add ability to integrate with cloud log services (e.g. sentry)