fixparser
Version:
FIX.Latest / 5.0 SP2 Parser / AI Agent Trading
94 lines (93 loc) • 3.14 kB
TypeScript
import type { ILogTransporter, Level, LogMessage } from 'fixparser-common';
import { type ConsoleFormat as Format } from 'fixparser-plugin-log-console';
/**
* Configuration options for logging output.
*
* @public
*/
export type LogOptions = {
name?: string;
id?: string;
level?: Level;
format?: Format;
transport?: ILogTransporter;
};
/**
* Logger class for handling FIX protocol logging.
* Provides methods for logging messages at different severity levels
* and supports custom log transports and formats.
*/
export declare class Logger {
#private;
/** Name of the logger instance */
name: string;
/** Unique identifier for the logger instance */
id: string;
/**
* Creates a new Logger instance with the specified options.
*
* @param {LogOptions} [options] - Configuration options for the logger
* @param {string} [options.name=''] - Name of the logger
* @param {string} [options.id] - Unique identifier for the logger (auto-generated if not provided)
* @param {Level} [options.level='info'] - Initial log level
* @param {Format} [options.format='json'] - Log message format
* @param {ILogTransporter} [options.transport] - Custom log transport (defaults to console)
*/
constructor(options?: LogOptions);
/**
* Processes a log message, adding metadata and sending it through the transport.
* Only processes messages if logging is enabled and the message level meets the current level.
*
* @param {LogMessage} msg - The message to process
* @returns {this} The logger instance for chaining
*/
private processMessage;
/**
* Logs a message at the specified level.
* If no level is specified, defaults to 'info'.
*
* @param {LogMessage} msg - The message to log
* @returns {this} The logger instance for chaining
*/
log(msg: LogMessage): this;
/**
* Logs a warning message.
*
* @param {Omit<LogMessage, 'level'>} msg - The message to log (level will be set to 'warn')
* @returns {this} The logger instance for chaining
*/
logWarning(msg: Omit<LogMessage, 'level'>): this;
/**
* Logs an error message.
*
* @param {Omit<LogMessage, 'level'>} msg - The message to log (level will be set to 'error')
* @returns {this} The logger instance for chaining
*/
logError(msg: Omit<LogMessage, 'level'>): this;
/**
* Sets whether the logger should be silent.
* When silent, no messages will be logged regardless of their level.
*
* @param {boolean} silent - Whether to silence the logger
*/
set silent(silent: boolean);
/**
* Gets whether the logger is currently silent.
*
* @returns {boolean} True if the logger is silent, false otherwise
*/
get silent(): boolean;
/**
* Gets the current log level.
*
* @returns {Level} The current log level
*/
get level(): Level;
/**
* Gets the current log format.
*
* @returns {Format} The current log format
*/
get format(): Format;
}
export type { Format };