Compare commits

..

No commits in common. "40f6bc572e06ecfafefd045a27fb4254f094aae1" and "4c68f237ff7cbf0cf612394ba73ad84fdb2a36f9" have entirely different histories.

3 changed files with 9 additions and 19 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@navy.gif/logger",
"version": "2.4.3",
"version": "2.4.2",
"description": "Logging thing",
"author": "Navy.gif",
"license": "MIT",

View File

@ -44,7 +44,6 @@ const customTypes: string[] = [];
const guard = '_logger';
const webhook: { url?: string, id?: string, token?: string } = {};
const pruneDays = 3;
const skipFileWrite = false;
type LogLevelType = {
debug: LogLevel,
@ -84,8 +83,7 @@ export type LoggerMasterOptions = SharedOptionsType & {
customColours?: { [key: string]: number | string },
broadcastLevel?: number,
webhook?: WebhookClientOptions,
pruneDays?: number,
skipFileWrite?: boolean
pruneDays?: number
}
const MasterOptions: LoggerMasterOptions = {
@ -97,8 +95,7 @@ const MasterOptions: LoggerMasterOptions = {
customColours,
broadcastLevel: 4,
webhook,
pruneDays,
skipFileWrite
pruneDays
};
export type LoggerClientOptions = SharedOptionsType;

View File

@ -51,7 +51,6 @@ class MasterLogger implements Logger
#rotateTO: NodeJS.Timeout;
#pruneInterval: NodeJS.Timer;
#pruneDays: number;
#skipFileWrite: boolean;
constructor (config = Defaults.MasterOptions)
{
@ -59,7 +58,7 @@ class MasterLogger implements Logger
const {
directory, customTypes = [], customStreams = [], customTypeMapping,
customColours, guard, fileRotationFreq, logLevel, logLevelMapping,
webhook, broadcastLevel, pruneDays, skipFileWrite
webhook, broadcastLevel, pruneDays
} = { ...Defaults.MasterOptions, ...config };
if (!directory)
@ -77,7 +76,6 @@ class MasterLogger implements Logger
addLogLevel(name, level);
});
this.#_guard = guard as string;
this.#skipFileWrite = skipFileWrite as boolean;
this.#types = [ ...customTypes, ...Defaults.Types ];
for (const type of this.#types)
@ -107,14 +105,11 @@ class MasterLogger implements Logger
this.#streamTypes = [ ...customStreams, 'error', 'default' ];
this.#streamTypeMapping = { ...Defaults.TypeStream, ...customTypeMapping };
if (this.#skipFileWrite)
this.#writeStreams = {};
else
this.#writeStreams = this.#streamTypes.reduce((acc, type) =>
{
acc[type] = this.loadFile(type);
return acc;
}, {} as WriteStreams);
this.#writeStreams = this.#streamTypes.reduce((acc, type) =>
{
acc[type] = this.loadFile(type);
return acc;
}, {} as WriteStreams);
// Startup day, used to keep track of file rotation
this.#rotationFreq = fileRotationFreq as number * DAY;
@ -237,8 +232,6 @@ class MasterLogger implements Logger
});
}
if (this.#skipFileWrite)
return;
const streamType = this.#streamTypeMapping[type] || 'default';
if (this.#writeStreams[streamType])
this.#writeStreams[streamType].write(`\n${type}${spacer} ${header}: ${subheader}${text}`);