@peacockproject/core
Version:
Type definitions for Peacock's core.
61 lines (60 loc) • 1.77 kB
TypeScript
import type { NextFunction, Request, Response } from "express";
import "winston-daily-rotate-file";
/**
* Represents the different log levels.
*/
export declare enum LogLevel {
/**
* For errors. Displays in red.
*/
ERROR = "error",
/**
* For warnings. Displays in yellow.
*/
WARN = "warn",
/**
* For information. Displays in blue.
* This is also the fallback for invalid log level values.
*/
INFO = "info",
/**
* For debugging. Displays in light blue.
*/
DEBUG = "debug",
/**
* For outputting stack traces.
*/
TRACE = "trace",
/**
* For extremely verbose purposes.
*/
SILLY = "silly"
}
/**
* Outputs all given arguments as a debug level indented JSON-message to the console.
*
* @param args The values to log.
*/
export declare function logDebug(...args: unknown[]): void;
/**
* Outputs a log message to the console.
*
* @param level The message's level.
* @param data The data to output.
* @param category The message's category.
* @see LogLevel
*
* @function log
*/
export declare function log(level: LogLevel, data: string | unknown, category?: LogCategory | string): void;
/**
* Express middleware that logs all requests and their details with the info log level.
*
* @param req The Express request object.
* @param _ The Express response object.
* @param next The Express next function.
* @see LogLevel.INFO
*/
export declare function loggingMiddleware(req: Request, _: Response, next?: NextFunction): void;
export declare function requestLoggingMiddleware(req: Request, res: Response, next?: NextFunction): void;
export declare function errorLoggingMiddleware(err: Error, req: Request, _: Response, next?: NextFunction): void;