Skip to content

Commit

Permalink
fix(logs): always log to supabase
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 committed Dec 8, 2023
1 parent 4272ef5 commit 7961254
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/adapters/adapters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function createAdapters() {
debit: new Settlement(supabaseClient),
settlement: new Settlement(supabaseClient),
label: new Label(supabaseClient),
logs: new Logs(supabaseClient, env.LOG_ENVIRONMENT, env.LOG_RETRY_LIMIT, env.LOG_LEVEL, null),
logs: new Logs(supabaseClient, env.LOG_RETRY_LIMIT, env.LOG_LEVEL, null),
locations: new Locations(supabaseClient),
super: new Super(supabaseClient),
},
Expand Down
14 changes: 2 additions & 12 deletions src/adapters/supabase/helpers/tables/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export class Logs {
private _context: ProbotContext | null = null;

private _maxLevel = -1;
private _environment = "development";
private _queue: LogInsert[] = []; // Your log queue
private _concurrency = 6; // Maximum concurrent requests
private _retryDelay = 1000; // Delay between retries in milliseconds
Expand Down Expand Up @@ -220,16 +219,9 @@ export class Logs {
// });
// }

constructor(
supabase: SupabaseClient,
environment: string,
retryLimit: number,
logLevel: LogLevel,
context: ProbotContext | null
) {
constructor(supabase: SupabaseClient, retryLimit: number, logLevel: LogLevel, context: ProbotContext | null) {
this._supabase = supabase;
this._context = context;
this._environment = environment;
this._retryLimit = retryLimit;
this._maxLevel = this._getNumericLevel(logLevel);
Logs.console = new PrettyLogs();
Expand Down Expand Up @@ -303,9 +295,7 @@ export class Logs {
.then(() => void 0)
.catch(() => Logs.console.fatal("Error adding logs to queue"));

if (this._environment === "development") {
Logs.console.ok(logInsert.log, logInsert);
}
Logs.console.ok(logInsert.log, logInsert);
}

static _commentMetaData(metadata: any, level: LogLevel) {
Expand Down
2 changes: 1 addition & 1 deletion src/bindings/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ runtime.logger = runtime.adapters.supabase.logs;
export async function bindEvents(eventContext: ProbotContext) {
const payload = eventContext.payload as Payload;
const eventName = payload?.action ? `${eventContext.name}.${payload?.action}` : eventContext.name; // some events wont have actions as this grows
const logger = new Logs(supabaseClient, env.LOG_ENVIRONMENT, env.LOG_RETRY_LIMIT, env.LOG_LEVEL, eventContext);
const logger = new Logs(supabaseClient, env.LOG_RETRY_LIMIT, env.LOG_LEVEL, eventContext);

logger.info("Event received", { id: eventContext.id, name: eventName });

Expand Down
1 change: 0 additions & 1 deletion src/types/configuration-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export function stringDuration(options?: StringOptions) {

const envConfigSchema = T.Object({
WEBHOOK_PROXY_URL: T.String({ format: "uri" }),
LOG_ENVIRONMENT: T.String({ default: "production" }),
LOG_LEVEL: T.Enum(LogLevel, { default: LogLevel.SILLY }),
LOG_RETRY_LIMIT: T.Number({ default: 8 }),
SUPABASE_URL: T.String({ format: "uri" }),
Expand Down

0 comments on commit 7961254

Please sign in to comment.