moved to zod, packages messed up still
This commit is contained in:
parent
15dd03c0ec
commit
a8ee4022bf
35 changed files with 3245 additions and 691 deletions
|
|
@ -1,55 +1,48 @@
|
|||
/**
|
||||
* Logging configuration using envalid
|
||||
* Logging configuration using Zod
|
||||
* Application logging settings without Loki (Loki config is in monitoring.ts)
|
||||
*/
|
||||
import { cleanEnv, str, bool, num } from 'envalid';
|
||||
import { cleanEnv, envValidators } from './env-utils';
|
||||
|
||||
const { str, bool, num, strWithChoices } = envValidators;
|
||||
|
||||
/**
|
||||
* Logging configuration with validation and defaults
|
||||
*/
|
||||
export const loggingConfig = cleanEnv(process.env, {
|
||||
// Basic Logging Settings
|
||||
LOG_LEVEL: str({
|
||||
default: 'info',
|
||||
choices: ['debug' , 'info' , 'warn' , 'error'],
|
||||
desc: 'Logging level'
|
||||
}),
|
||||
LOG_FORMAT: str({
|
||||
default: 'json',
|
||||
choices: ['json', 'simple', 'combined'],
|
||||
desc: 'Log output format'
|
||||
}),
|
||||
LOG_CONSOLE: bool({ default: true, desc: 'Enable console logging' }),
|
||||
LOG_FILE: bool({ default: false, desc: 'Enable file logging' }),
|
||||
LOG_LEVEL: strWithChoices(['debug', 'info', 'warn', 'error'], 'info', 'Logging level'),
|
||||
LOG_FORMAT: strWithChoices(['json', 'simple', 'combined'], 'json', 'Log output format'),
|
||||
LOG_CONSOLE: bool(true, 'Enable console logging'),
|
||||
LOG_FILE: bool(false, 'Enable file logging'),
|
||||
|
||||
// File Logging Settings
|
||||
LOG_FILE_PATH: str({ default: 'logs', desc: 'Log file directory path' }),
|
||||
LOG_FILE_MAX_SIZE: str({ default: '20m', desc: 'Maximum log file size' }),
|
||||
LOG_FILE_MAX_FILES: num({ default: 14, desc: 'Maximum number of log files to keep' }),
|
||||
LOG_FILE_DATE_PATTERN: str({ default: 'YYYY-MM-DD', desc: 'Log file date pattern' }),
|
||||
LOG_FILE_PATH: str('logs', 'Log file directory path'),
|
||||
LOG_FILE_MAX_SIZE: str('20m', 'Maximum log file size'),
|
||||
LOG_FILE_MAX_FILES: num(14, 'Maximum number of log files to keep'),
|
||||
LOG_FILE_DATE_PATTERN: str('YYYY-MM-DD', 'Log file date pattern'),
|
||||
|
||||
// Error Logging
|
||||
LOG_ERROR_FILE: bool({ default: true, desc: 'Enable separate error log file' }),
|
||||
LOG_ERROR_STACK: bool({ default: true, desc: 'Include stack traces in error logs' }),
|
||||
LOG_ERROR_FILE: bool(true, 'Enable separate error log file'),
|
||||
LOG_ERROR_STACK: bool(true, 'Include stack traces in error logs'),
|
||||
|
||||
// Performance Logging
|
||||
LOG_PERFORMANCE: bool({ default: false, desc: 'Enable performance logging' }),
|
||||
LOG_SQL_QUERIES: bool({ default: false, desc: 'Log SQL queries' }),
|
||||
LOG_HTTP_REQUESTS: bool({ default: true, desc: 'Log HTTP requests' }),
|
||||
LOG_PERFORMANCE: bool(false, 'Enable performance logging'),
|
||||
LOG_SQL_QUERIES: bool(false, 'Log SQL queries'),
|
||||
LOG_HTTP_REQUESTS: bool(true, 'Log HTTP requests'),
|
||||
|
||||
// Structured Logging
|
||||
LOG_STRUCTURED: bool({ default: true, desc: 'Use structured logging format' }),
|
||||
LOG_TIMESTAMP: bool({ default: true, desc: 'Include timestamps in logs' }),
|
||||
LOG_CALLER_INFO: bool({ default: false, desc: 'Include caller information in logs' }),
|
||||
|
||||
// Log Filtering
|
||||
LOG_SILENT_MODULES: str({ default: '', desc: 'Comma-separated list of modules to silence' }),
|
||||
LOG_VERBOSE_MODULES: str({ default: '', desc: 'Comma-separated list of modules for verbose logging' }),
|
||||
LOG_STRUCTURED: bool(true, 'Use structured logging format'),
|
||||
LOG_TIMESTAMP: bool(true, 'Include timestamps in logs'),
|
||||
LOG_CALLER_INFO: bool(false, 'Include caller information in logs'),
|
||||
// Log Filtering
|
||||
LOG_SILENT_MODULES: str('', 'Comma-separated list of modules to silence'),
|
||||
LOG_VERBOSE_MODULES: str('', 'Comma-separated list of modules for verbose logging'),
|
||||
|
||||
// Application Context
|
||||
LOG_SERVICE_NAME: str({ default: 'stock-bot', desc: 'Service name for log context' }),
|
||||
LOG_SERVICE_VERSION: str({ default: '1.0.0', desc: 'Service version for log context' }),
|
||||
LOG_ENVIRONMENT: str({ default: 'development', desc: 'Environment for log context' }),
|
||||
LOG_SERVICE_NAME: str('stock-bot', 'Service name for log context'),
|
||||
LOG_SERVICE_VERSION: str('1.0.0', 'Service version for log context'),
|
||||
LOG_ENVIRONMENT: str('development', 'Environment for log context'),
|
||||
});
|
||||
|
||||
// Export typed configuration object
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue