feat(logging): Wave 1 - logging infrastructure complete
- Add logging config to config.yaml with level, auditRetention, appRetention - Add 4 global exception handlers (uncaughtException, unhandledRejection, render-process-gone, child-process-gone) - Create audit-logger.ts with JSONL format and 30-day rotation - Define IPC logger channels (LOGGER_FORWARD) and preload API - Define audit types (AuditAction enum, AuditEntry interface, AuditStatus enum) - Add unit tests for audit logger All typechecks passing. Wave 1 complete.
This commit is contained in:
44
src/main/types/audit.types.ts
Normal file
44
src/main/types/audit.types.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Audit log types and interfaces
|
||||
*/
|
||||
|
||||
/**
|
||||
* Audit action enumeration
|
||||
*/
|
||||
export enum AuditAction {
|
||||
LOGIN = 'LOGIN',
|
||||
LOGOUT = 'LOGOUT',
|
||||
EXTRACT = 'EXTRACT',
|
||||
CLEAN = 'CLEAN',
|
||||
SETTINGS_CHANGE = 'SETTINGS_CHANGE'
|
||||
}
|
||||
|
||||
/**
|
||||
* Audit status enumeration
|
||||
*/
|
||||
export enum AuditStatus {
|
||||
SUCCESS = 'SUCCESS',
|
||||
FAILURE = 'FAILURE'
|
||||
}
|
||||
|
||||
/**
|
||||
* Audit entry interface
|
||||
*/
|
||||
export interface AuditEntry {
|
||||
/** Timestamp of the action */
|
||||
timestamp: Date
|
||||
/** Action performed */
|
||||
action: AuditAction
|
||||
/** User ID who performed the action */
|
||||
userId: string
|
||||
/** Username who performed the action */
|
||||
username: string
|
||||
/** Computer name where action was performed */
|
||||
computerName: string
|
||||
/** Resource affected by the action */
|
||||
resource?: string
|
||||
/** Status of the action */
|
||||
status: AuditStatus
|
||||
/** Additional metadata in JSON format */
|
||||
metadata?: string
|
||||
}
|
||||
@@ -113,6 +113,15 @@ export const erpSystemConfigSchema = z.object({
|
||||
url: z.string().url('ERP URL must be a valid URL')
|
||||
})
|
||||
|
||||
/**
|
||||
* 日志配置 Schema
|
||||
*/
|
||||
export const loggingConfigSchema = z.object({
|
||||
level: z.enum(['error', 'warn', 'info', 'debug', 'verbose']).default('info'),
|
||||
auditRetention: z.number().int().min(1).max(365).default(30),
|
||||
appRetention: z.number().int().min(1).max(365).default(14)
|
||||
})
|
||||
|
||||
/**
|
||||
* 完整应用配置 Schema
|
||||
*/
|
||||
@@ -122,7 +131,8 @@ export const fullConfigSchema = z.object({
|
||||
paths: pathsConfigSchema,
|
||||
extraction: extractionConfigSchema,
|
||||
validation: validationConfigSchema,
|
||||
orderResolution: orderResolutionSchema
|
||||
orderResolution: orderResolutionSchema,
|
||||
logging: loggingConfigSchema
|
||||
})
|
||||
|
||||
/**
|
||||
@@ -133,6 +143,7 @@ export type DatabaseConfig = z.infer<typeof databaseConfigSchema>
|
||||
export type MySqlConfig = z.infer<typeof mysqlConfigSchema>
|
||||
export type SqlServerConfig = z.infer<typeof sqlServerConfigSchema>
|
||||
export type ErpSystemConfig = z.infer<typeof erpSystemConfigSchema>
|
||||
export type LoggingConfig = z.infer<typeof loggingConfigSchema>
|
||||
|
||||
/**
|
||||
* 验证并解析配置
|
||||
|
||||
Reference in New Issue
Block a user