UNPKG

strogger

Version:

📊 A modern structured logging library with functional programming, duck-typing, and comprehensive third-party integrations

122 lines • 6.88 kB
export declare class LoggerError extends Error { readonly code: string; readonly details?: Record<string, unknown> | undefined; constructor(message: string, code: string, details?: Record<string, unknown> | undefined); } export declare class TransportError extends LoggerError { readonly transportName: string; constructor(message: string, transportName: string, details?: Record<string, unknown>); } export declare class ConfigurationError extends LoggerError { constructor(message: string, details?: Record<string, unknown>); } export declare class ValidationError extends LoggerError { constructor(message: string, details?: Record<string, unknown>); } export declare const ERROR_MESSAGES: { readonly NEW_RELIC_MISSING_API_KEY: { readonly message: "New Relic transport requires NEW_RELIC_LICENSE_KEY environment variable"; readonly solution: "Set NEW_RELIC_LICENSE_KEY in your environment variables or pass apiKey option"; readonly example: "NEW_RELIC_LICENSE_KEY=your-license-key-here"; }; readonly NEW_RELIC_MISSING_ACCOUNT_ID: { readonly message: "New Relic transport requires NEW_RELIC_ACCOUNT_ID environment variable"; readonly solution: "Set NEW_RELIC_ACCOUNT_ID in your environment variables or pass accountId option"; readonly example: "NEW_RELIC_ACCOUNT_ID=your-account-id-here"; }; readonly NEW_RELIC_API_ERROR: { readonly message: "Failed to send logs to New Relic API"; readonly solution: "Check your API key, account ID, and network connectivity"; }; readonly DATADOG_MISSING_API_KEY: { readonly message: "DataDog transport requires DATADOG_API_KEY environment variable"; readonly solution: "Set DATADOG_API_KEY in your environment variables"; readonly example: "DATADOG_API_KEY=your-api-key-here"; }; readonly DATADOG_API_ERROR: { readonly message: "Failed to send logs to DataDog API"; readonly solution: "Check your API key and network connectivity"; }; readonly CLOUDWATCH_MISSING_CREDENTIALS: { readonly message: "CloudWatch transport requires AWS credentials"; readonly solution: "Configure AWS credentials via environment variables, IAM role, or AWS credentials file"; readonly example: "AWS_ACCESS_KEY_ID=your-key\nAWS_SECRET_ACCESS_KEY=your-secret"; }; readonly CLOUDWATCH_MISSING_LOG_GROUP: { readonly message: "CloudWatch transport requires logGroupName option"; readonly solution: "Provide logGroupName in transport options or set CLOUDWATCH_LOG_GROUP environment variable"; readonly example: "logGroupName: \"/aws/lambda/my-function\""; }; readonly CLOUDWATCH_LOG_GROUP_NOT_FOUND: { readonly message: "CloudWatch log group does not exist"; readonly solution: "Create the log group in CloudWatch before using this transport"; readonly example: "aws logs create-log-group --log-group-name \"/aws/lambda/my-function\""; }; readonly CLOUDWATCH_API_ERROR: { readonly message: "Failed to send logs to CloudWatch"; readonly solution: "Check your AWS credentials, region, and network connectivity"; }; readonly TRANSPORT_INITIALIZATION_FAILED: { readonly message: "Failed to initialize transport"; readonly solution: "Check transport configuration and required dependencies"; }; readonly TRANSPORT_SEND_FAILED: { readonly message: "Failed to send log entry to transport"; readonly solution: "Check transport configuration and network connectivity"; }; readonly MISSING_SERVICE_NAME: { readonly message: "Logger configuration requires serviceName"; readonly solution: "Set SERVICE_NAME environment variable or provide serviceName in config"; readonly example: "SERVICE_NAME=my-service"; }; readonly INVALID_LOG_LEVEL: { readonly message: "Invalid log level specified"; readonly solution: "Use one of: DEBUG, INFO, WARN, ERROR, FATAL"; readonly example: "LOG_LEVEL=INFO"; }; readonly ENVIRONMENT_VALIDATION_FAILED: { readonly message: "Environment configuration validation failed"; readonly solution: "Check your environment variables and configuration"; }; readonly FORMATTER_MISSING: { readonly message: "Logger requires a formatter"; readonly solution: "Provide a formatter object with a format(entry) method"; readonly example: "formatter: createJsonFormatter()"; }; readonly PERFORMANCE_MONITOR_INITIALIZATION_FAILED: { readonly message: "Failed to initialize performance monitor"; readonly solution: "Check performance monitor configuration"; }; readonly SPLUNK_MISSING_HEC_URL: { readonly message: "Splunk transport requires SPLUNK_HEC_URL environment variable"; readonly solution: "Set SPLUNK_HEC_URL in your environment variables"; readonly example: "SPLUNK_HEC_URL=https://your-splunk-instance:8088/services/collector"; }; readonly SPLUNK_MISSING_HEC_TOKEN: { readonly message: "Splunk transport requires SPLUNK_HEC_TOKEN environment variable"; readonly solution: "Set SPLUNK_HEC_TOKEN in your environment variables"; readonly example: "SPLUNK_HEC_TOKEN=your-hec-token-here"; }; readonly SPLUNK_API_ERROR: { readonly message: "Failed to send logs to Splunk HEC"; readonly solution: "Check your HEC URL, token, and network connectivity"; }; readonly ELASTICSEARCH_MISSING_AUTH: { readonly message: "Elasticsearch transport requires authentication"; readonly solution: "Set ELASTICSEARCH_API_KEY or ELASTICSEARCH_USERNAME/PASSWORD"; readonly example: "ELASTICSEARCH_API_KEY=your-api-key-here"; }; readonly ELASTICSEARCH_MISSING_DATE: { readonly message: "Date string is missing for Elasticsearch index pattern"; readonly solution: "Check date generation logic and ensure valid date string is produced"; }; readonly ELASTICSEARCH_API_ERROR: { readonly message: "Failed to send logs to Elasticsearch"; readonly solution: "Check your connection URL, authentication, and network connectivity"; }; }; export declare const createDetailedError: (errorKey: keyof typeof ERROR_MESSAGES, transportName?: string, additionalDetails?: Record<string, unknown>) => TransportError | LoggerError; export declare const validateEnvironmentVariable: (name: string, value: string | undefined, required?: boolean) => void; export declare const validateTransportConfig: (transportName: string, config: Record<string, unknown>, requiredFields: string[]) => void; export declare const handleTransportError: (error: unknown, transportName: string, fallbackToConsole?: boolean) => void; //# sourceMappingURL=errors.d.ts.map