import { LoggingFiles } from "./filewriter"; import { LoggingBase, LoggingBaseOptions } from "@hibas123/logging"; export interface LoggingOptions extends LoggingBaseOptions { files: boolean | { /** * Filename/path of the logfile. Skip if generated with name */ logfile: string; /** * Filename/path of the logfile. Skip if generated with name */ errorfile: string; } } export class LoggingExtended extends LoggingBase { constructor(config: Partial | string = {}) { super(config); if (typeof config === "string" || config.files !== false) { let logfile: string; let errorfile: string; if (typeof config !== "string" && typeof config.files === "object") { logfile = config.files.logfile; errorfile = config.files.errorfile; } else { let name = this.name ? "." + this.name : ""; logfile = `./logs/all${name}.log`; errorfile = `./logs/error${name}.log`; } if (logfile) { this.addAdapter(new LoggingFiles(logfile)); } if (errorfile) { this.addAdapter(new LoggingFiles(errorfile, true)); } } } } export let Logging: LoggingExtended = undefined; if (process.env.LOGGING_NO_DEFAULT !== "true") { Logging = new LoggingExtended(); } export default Logging;