From 3fddab4de0e28a952879a8623ef0ad5ab6a24b3a Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Fri, 30 Aug 2024 16:56:18 +0100 Subject: [PATCH] chore: place levelsToLog in postingConfig, optionalize --- src/logs.ts | 10 +++++----- tests/logs.test.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/logs.ts b/src/logs.ts index d7bf033..9f8ccea 100644 --- a/src/logs.ts +++ b/src/logs.ts @@ -6,23 +6,23 @@ import { LogParams, LogReturn, Metadata, LogLevel } from "./types/log-types"; type SupabaseConfig = { supabaseKey: string; supabaseUrl: string; -} | null; - + levelsToLog: LogLevel[]; +} export class Logs { private _maxLevel = -1; static console: PrettyLogs; private _supabase: SupabaseClient | null = null; private pluginName: string; - private _levelsToLog: LogLevel[] = ["fatal"]; + private _levelsToLog: LogLevel[] = []; - constructor(level: LogLevel, pluginName: string, postingConfig: SupabaseConfig, levelsToLog: LogLevel[] = ["fatal"]) { + constructor(level: LogLevel, pluginName: string, postingConfig?: SupabaseConfig) { this._maxLevel = this._getNumericLevel(level); Logs.console = new PrettyLogs(); this.pluginName = pluginName; - this._levelsToLog = levelsToLog; if (postingConfig) { + this._levelsToLog = postingConfig.levelsToLog; if (postingConfig.supabaseKey && postingConfig.supabaseUrl) { this._supabase = createClient(postingConfig.supabaseUrl, postingConfig.supabaseKey); } diff --git a/tests/logs.test.ts b/tests/logs.test.ts index 73a745f..df71546 100644 --- a/tests/logs.test.ts +++ b/tests/logs.test.ts @@ -6,7 +6,7 @@ describe("Logs", () => { let logs: Logs; beforeEach(() => { - logs = new Logs(LOG_LEVEL.DEBUG); + logs = new Logs(LOG_LEVEL.DEBUG, "test") }); it("should log an 'ok' message", () => {