export { LoggingFiles } from "./filewriter"; import { LoggingFiles } from "./filewriter"; import { LoggingBase as LoggingBaseOriginal, LoggingBaseOptions } from "@hibas123/logging"; export interface LoggingOptions extends LoggingBaseOptions { files: boolean | { /** * Filename/path of the logfile. Skip if generated with name. * * If not wanted pass null */ logfile?: string | null; /** * Filename/path of the logfile. Skip if generated with name. * * If not wanted pass null */ errorfile?: string | null; } } export class LoggingBase extends LoggingBaseOriginal { 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; } let name = this.name ? "." + this.name : ""; if (!logfile && logfile !== null) logfile = `./logs/all${name}.log`; if (!errorfile && errorfile !== null) errorfile = `./logs/error${name}.log`; if (logfile) this.addAdapter(new LoggingFiles(logfile)); if (errorfile) this.addAdapter(new LoggingFiles(errorfile, true)); } } } export let Logging: LoggingBase = undefined; if (process.env.LOGGING_NO_DEFAULT !== "true") { Logging = new LoggingBase(); } export default Logging;