amazon-seller-mcp
Version:
Model Context Protocol (MCP) client for Amazon Selling Partner API
185 lines (184 loc) • 4.73 kB
TypeScript
/**
* Logging system for Amazon Seller MCP Client
*
* This file contains the logging system implementation, including:
* - Configurable logging levels
* - Sensitive data redaction
* - Log formatting
*/
import winston from 'winston';
import { LogMetadata, HttpRequest, HttpResponse } from '../types/common.js';
/**
* Log levels
*/
export declare enum LogLevel {
ERROR = "error",
WARN = "warn",
INFO = "info",
HTTP = "http",
DEBUG = "debug"
}
/**
* Logger configuration options
*/
export interface LoggerConfig {
/**
* Log level
* @default 'info'
*/
level?: LogLevel;
/**
* Whether to log to console
* @default true
*/
console?: boolean;
/**
* File path to log to
* @default undefined (no file logging)
*/
filePath?: string;
/**
* Whether to redact sensitive data
* @default true
*/
redactSensitiveData?: boolean;
/**
* Custom redaction patterns
* Each key is a field name to redact, and the value is the pattern to match
*/
redactionPatterns?: Record<string, RegExp>;
/**
* Custom formatter function
*/
formatter?: winston.Logform.Format;
}
/**
* Redact sensitive data from log messages
*
* @param message Log message
* @param patterns Redaction patterns
* @returns Redacted message
*/
export declare function redactSensitiveData(message: string, patterns?: Record<string, RegExp>): string;
/**
* Create a Winston logger instance
*
* @param config Logger configuration
* @returns Winston logger instance
*/
export declare function createLogger(config?: LoggerConfig): winston.Logger;
/**
* Configure the default logger
*
* @param config Logger configuration
*/
export declare function configureLogger(config: LoggerConfig): void;
/**
* Get the default logger instance
*
* @returns Default logger instance
*/
export declare function getLogger(): winston.Logger;
/**
* Log an error message
*
* @param message Error message
* @param meta Additional metadata
*/
export declare function error(message: string, meta?: LogMetadata): void;
/**
* Log a warning message
*
* @param message Warning message
* @param meta Additional metadata
*/
export declare function warn(message: string, meta?: LogMetadata): void;
/**
* Log an info message
*
* @param message Info message
* @param meta Additional metadata
*/
export declare function info(message: string, meta?: LogMetadata): void;
/**
* Log an HTTP message
*
* @param message HTTP message
* @param meta Additional metadata
*/
export declare function http(message: string, meta?: LogMetadata): void;
/**
* Log a debug message
*
* @param message Debug message
* @param meta Additional metadata
*/
export declare function debug(message: string, meta?: LogMetadata): void;
/**
* Create a child logger with additional metadata
*
* @param meta Default metadata to include with all log messages
* @returns Child logger
*/
export declare function createChildLogger(meta: LogMetadata): winston.Logger;
/**
* Create a request logger middleware for HTTP requests
*
* @returns Request logger middleware
*/
export declare function createRequestLogger(): (req: HttpRequest, res: HttpResponse, next: () => void) => void;
/**
* Logger class wrapper for easier instantiation and testing
*/
export declare class Logger {
private logger;
/**
* Create a new Logger instance
* @param config Logger configuration
*/
constructor(config?: LoggerConfig);
/**
* Log an error message
*/
error(message: string, meta?: LogMetadata): void;
/**
* Log a warning message
*/
warn(message: string, meta?: LogMetadata): void;
/**
* Log an info message
*/
info(message: string, meta?: LogMetadata): void;
/**
* Log an HTTP message
*/
http(message: string, meta?: LogMetadata): void;
/**
* Log a debug message
*/
debug(message: string, meta?: LogMetadata): void;
/**
* Create a child logger with additional metadata
*/
createChild(meta: LogMetadata): winston.Logger;
/**
* Get the underlying winston logger
*/
getWinstonLogger(): winston.Logger;
}
declare const _default: {
LogLevel: typeof LogLevel;
Logger: typeof Logger;
configureLogger: typeof configureLogger;
getLogger: typeof getLogger;
createLogger: typeof createLogger;
error: typeof error;
warn: typeof warn;
info: typeof info;
http: typeof http;
debug: typeof debug;
createChildLogger: typeof createChildLogger;
createRequestLogger: typeof createRequestLogger;
redactSensitiveData: typeof redactSensitiveData;
};
export default _default;