WIP! A BB-style forum, on the ATmosphere!
We're still working... we'll be back soon when we have something to show off!
node
typescript
hono
htmx
atproto
1import consola from "consola";
2import type { Logger, LogAttributes } from "@atbb/logger";
3
4/**
5 * CLI logger adapter that wraps consola to satisfy the Logger interface.
6 *
7 * This allows ForumAgent (which requires a structured Logger) to log through
8 * consola for consistent CLI output. The CLI's own user-facing messages
9 * continue to use consola directly.
10 */
11class ConsolaLoggerAdapter implements Logger {
12 debug(message: string, attributes?: LogAttributes): void {
13 if (attributes) {
14 consola.debug(message, attributes);
15 } else {
16 consola.debug(message);
17 }
18 }
19
20 info(message: string, attributes?: LogAttributes): void {
21 if (attributes) {
22 consola.info(message, attributes);
23 } else {
24 consola.info(message);
25 }
26 }
27
28 warn(message: string, attributes?: LogAttributes): void {
29 if (attributes) {
30 consola.warn(message, attributes);
31 } else {
32 consola.warn(message);
33 }
34 }
35
36 error(message: string, attributes?: LogAttributes): void {
37 if (attributes) {
38 consola.error(message, attributes);
39 } else {
40 consola.error(message);
41 }
42 }
43
44 fatal(message: string, attributes?: LogAttributes): void {
45 if (attributes) {
46 consola.fatal(message, attributes);
47 } else {
48 consola.fatal(message);
49 }
50 }
51
52 child(_attributes: LogAttributes): Logger {
53 // consola doesn't support child loggers with base attributes,
54 // so return this same instance
55 return this;
56 }
57
58 async shutdown(): Promise<void> {
59 // No-op — consola doesn't need cleanup
60 }
61}
62
63export const logger: Logger = new ConsolaLoggerAdapter();