Skip to content

Commit

Permalink
chore: place levelsToLog in postingConfig, optionalize
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Aug 30, 2024
1 parent 48165f5 commit 3fddab4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/logs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down

0 comments on commit 3fddab4

Please sign in to comment.