making files in config nullabel to disable
This commit is contained in:
parent
0b75f8ddf8
commit
096c5910c3
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hibas123/nodelogging",
|
||||
"version": "1.6.0",
|
||||
"version": "1.6.1",
|
||||
"description": "",
|
||||
"main": "out/index.js",
|
||||
"types": "out/index.d.ts",
|
||||
|
25
src/index.ts
25
src/index.ts
@ -5,13 +5,17 @@ import { LoggingBase as LoggingBaseOriginal, LoggingBaseOptions } from "@hibas12
|
||||
export interface LoggingOptions extends LoggingBaseOptions {
|
||||
files: boolean | {
|
||||
/**
|
||||
* Filename/path of the logfile. Skip if generated with name
|
||||
* Filename/path of the logfile. Skip if generated with name.
|
||||
*
|
||||
* If not wanted pass null
|
||||
*/
|
||||
logfile: string;
|
||||
logfile?: string | null;
|
||||
/**
|
||||
* Filename/path of the logfile. Skip if generated with name
|
||||
* Filename/path of the logfile. Skip if generated with name.
|
||||
*
|
||||
* If not wanted pass null
|
||||
*/
|
||||
errorfile: string;
|
||||
errorfile?: string | null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,22 +29,23 @@ export class LoggingBase extends LoggingBaseOriginal {
|
||||
if (typeof config !== "string" && typeof config.files === "object") {
|
||||
logfile = config.files.logfile;
|
||||
errorfile = config.files.errorfile;
|
||||
} else {
|
||||
}
|
||||
|
||||
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) {
|
||||
if (logfile)
|
||||
this.addAdapter(new LoggingFiles(logfile));
|
||||
}
|
||||
|
||||
if (errorfile) {
|
||||
|
||||
if (errorfile)
|
||||
this.addAdapter(new LoggingFiles(errorfile, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export let Logging: LoggingBase = undefined;
|
||||
if (process.env.LOGGING_NO_DEFAULT !== "true") {
|
||||
|
Loading…
Reference in New Issue
Block a user