Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 1x 1x 1x 1x 3x 3x 3x | /**
* Logging Configuration
*
* Centralized configuration for the logging system.
* Supports environment-specific settings and external service integration.
*/
export type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
export interface LoggingConfig {
level: LogLevel;
transport: 'console' | 'json';
pretty: boolean;
redactPaths: string[];
service: string;
environment: string;
version: string;
}
/**
* Paths to redact from log output for security
* These fields will be replaced with '[REDACTED]'
*/
const REDACT_PATHS = [
'password',
'token',
'accessToken',
'refreshToken',
'authorization',
'cookie',
'creditCard',
'cardNumber',
'cvv',
'ssn',
'secret',
'apiKey',
'privateKey',
'sessionToken',
'otp',
'totpSecret',
];
const isProduction = process.env.NODE_ENV === 'production';
const isDevelopment = process.env.NODE_ENV === 'development';
/**
* Environment-specific logging configuration
*/
export const loggingConfig: LoggingConfig = {
level: (process.env.LOG_LEVEL as LogLevel) || (isProduction ? 'info' : 'debug'),
transport: isProduction ? 'json' : 'console',
pretty: isDevelopment,
redactPaths: REDACT_PATHS,
service: 'elite-events',
environment: process.env.NODE_ENV || 'development',
version: process.env.npm_package_version || '1.0.0',
};
/**
* Log category types for structured logging
*/
export type LogCategory =
| 'API'
| 'DATABASE'
| 'AUTH'
| 'CLIENT'
| 'PAYMENT'
| 'ORDER'
| 'CART'
| 'PRODUCT'
| 'SUPPORT'
| 'SYSTEM'
| 'PERFORMANCE'
| 'CRON'
| 'SECURITY'
| 'EXTERNAL';
/**
* Get the numeric priority of a log level
* Lower number = higher priority (more severe)
*/
export function getLogLevelPriority(level: LogLevel): number {
const priorities: Record<LogLevel, number> = {
fatal: 0,
error: 1,
warn: 2,
info: 3,
debug: 4,
trace: 5,
};
return priorities[level];
}
/**
* Check if a log level should be output based on current config
*/
export function shouldLog(level: LogLevel): boolean {
return getLogLevelPriority(level) <= getLogLevelPriority(loggingConfig.level);
}
|