Skip to content

Commit f525b1c

Browse files
committed
fix: internal logger usage
1 parent 8554fc4 commit f525b1c

File tree

7 files changed

+17
-36
lines changed

7 files changed

+17
-36
lines changed

packages/commandkit/src/analytics/analytics-engine.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { CommandKit } from '../commandkit';
22
import { Logger } from '../logger/Logger';
3-
import { warnUnstable } from '../utils/warn-unstable';
43
import {
54
AnalyticsEvent,
65
AnalyticsProvider,
@@ -83,10 +82,7 @@ export class AnalyticsEngine {
8382
try {
8483
await this.#provider!.identify?.(this, event);
8584
} catch (error) {
86-
Logger.error(
87-
`Error identifying with provider ${this.#provider!.name}`,
88-
error,
89-
);
85+
Logger.error`Error identifying with provider ${this.#provider!.name}: ${error}`;
9086
}
9187
}
9288

@@ -102,10 +98,7 @@ export class AnalyticsEngine {
10298
if (await this.#doNotTrack(event)) return;
10399
await this.#provider!.track(this, event);
104100
} catch (error) {
105-
Logger.error(
106-
`Error tracking ${event.name} event with provider ${this.#provider!.name}`,
107-
error,
108-
);
101+
Logger.error`Error tracking ${event.name} event with provider ${this.#provider!.name}: ${error}`;
109102
}
110103
}
111104

packages/commandkit/src/app/handlers/AppCommandHandler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ export class AppCommandHandler {
729729

730730
this.loadedMiddlewares.set(id, { middleware, data });
731731
} catch (error) {
732-
Logger.error(`Failed to load middleware ${id}`, error);
732+
Logger.error`Failed to load middleware ${id}: ${error}`;
733733
}
734734
}
735735

@@ -865,7 +865,7 @@ export class AppCommandHandler {
865865
},
866866
});
867867
} catch (error) {
868-
Logger.error(`Failed to load command ${command.name} (${id})`, error);
868+
Logger.error`Failed to load command ${command.name} (${id}): ${error}`;
869869
}
870870
}
871871

packages/commandkit/src/app/handlers/AppEventsHandler.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,9 @@ export class AppEventsHandler {
217217
}
218218

219219
// Otherwise log the error as usual
220-
Logger.error(
221-
`Error handling event ${name}${
222-
namespace ? ` of namespace ${namespace}` : ''
223-
}`,
224-
e,
225-
);
220+
Logger.error`Error handling event ${name}${
221+
namespace ? ` of namespace ${namespace}` : ''
222+
}: ${e}`;
226223
}
227224
}
228225
},
@@ -284,12 +281,9 @@ export class AppEventsHandler {
284281
}
285282

286283
// Otherwise log the error as usual
287-
Logger.error(
288-
`Error handling event ${name}${
289-
namespace ? ` of namespace ${namespace}` : ''
290-
}`,
291-
e,
292-
);
284+
Logger.error`Error handling event ${name}${
285+
namespace ? ` of namespace ${namespace}` : ''
286+
}: ${e}`;
293287
}
294288
},
295289
);

packages/commandkit/src/app/middlewares/permissions.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ export async function beforeExecute(ctx: MiddlewareContext) {
4343
}
4444
}
4545
} catch (error) {
46-
Logger.error(
47-
`Could not send 'Server-only command' DM to user ${interaction?.user.id ?? message?.author.id} for command ${command.command.name}.`,
48-
error,
49-
);
46+
Logger.error`Could not send 'Server-only command' DM to user ${interaction?.user.id ?? message?.author.id} for command ${command.command.name}: ${error}`;
5047
}
5148

5249
return ctx.cancel(); // Stop the command from executing
@@ -153,10 +150,7 @@ export async function beforeExecute(ctx: MiddlewareContext) {
153150
});
154151
}
155152
} catch (error) {
156-
Logger.error(
157-
`Could not send 'Not enough permissions' reply to user ${interaction?.user.id ?? message?.author.id} for command ${command.command.name}.`,
158-
error,
159-
);
153+
Logger.error`Could not send 'Not enough permissions' reply to user ${interaction?.user.id ?? message?.author.id} for command ${command.command.name}: ${error}`;
160154
}
161155

162156
return ctx.cancel(); // Stop the command from executing

packages/commandkit/src/app/register/CommandRegistrar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export class CommandRegistrar {
172172
`✨ Refreshed ${data.length} global application (/) commands`,
173173
);
174174
} catch (e) {
175-
Logger.error('Failed to update global application (/) commands', e);
175+
Logger.error`Failed to update global application (/) commands: ${e}`;
176176
}
177177
}
178178

@@ -253,7 +253,7 @@ export class CommandRegistrar {
253253

254254
Logger.info(`✨ Refreshed ${count} guild application (/) commands`);
255255
} catch (e) {
256-
Logger.error('Failed to update guild application (/) commands', e);
256+
Logger.error`Failed to update guild application (/) commands: ${e}`;
257257
}
258258
}
259259
}

packages/commandkit/src/commandkit.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export class CommandKit extends EventEmitter {
207207
try {
208208
await hook(this);
209209
} catch (e) {
210-
Logger.error('Error while executing bootstrap hook: ', e);
210+
Logger.error`Error while executing bootstrap hook: ${e}`;
211211
} finally {
212212
bootstrapHooks.delete(hook);
213213
}
@@ -222,7 +222,7 @@ export class CommandKit extends EventEmitter {
222222
try {
223223
await hook(this);
224224
} catch (e) {
225-
Logger.error('Error while executing application bootstrap hook: ', e);
225+
Logger.error`Error while executing application bootstrap hook: ${e}`;
226226
} finally {
227227
onApplicationBootstrapHooks.delete(hook);
228228
}

packages/commandkit/src/plugins/plugin-runtime/CommandKitPluginRuntime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export class CommandKitPluginRuntime {
144144
return true;
145145
}
146146

147-
Logger.error(`Plugin "${plugin.name}" failed`, e?.stack || e);
147+
Logger.error`Plugin "${plugin.name}" failed: ${e?.stack || e}`;
148148
}
149149
}
150150

0 commit comments

Comments
 (0)