about summary refs log tree commit diff
path: root/src/state/messages/events/agent.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/state/messages/events/agent.ts')
-rw-r--r--src/state/messages/events/agent.ts32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/state/messages/events/agent.ts b/src/state/messages/events/agent.ts
index 9244a4fa5..9890eee3f 100644
--- a/src/state/messages/events/agent.ts
+++ b/src/state/messages/events/agent.ts
@@ -3,7 +3,7 @@ import EventEmitter from 'eventemitter3'
 import {nanoid} from 'nanoid/non-secure'
 
 import {networkRetry} from '#/lib/async/retry'
-import {logger} from '#/logger'
+import {Logger} from '#/logger'
 import {
   BACKGROUND_POLL_INTERVAL,
   DEFAULT_POLL_INTERVAL,
@@ -19,6 +19,7 @@ import {
 import {DM_SERVICE_HEADERS} from '#/state/queries/messages/const'
 
 const LOGGER_CONTEXT = 'MessagesEventBus'
+const logger = Logger.create(Logger.Context.DMsAgent)
 
 export class MessagesEventBus {
   private id: string
@@ -90,17 +91,17 @@ export class MessagesEventBus {
   }
 
   background() {
-    logger.debug(`${LOGGER_CONTEXT}: background`, {}, logger.DebugContext.convo)
+    logger.debug(`${LOGGER_CONTEXT}: background`, {})
     this.dispatch({event: MessagesEventBusDispatchEvent.Background})
   }
 
   suspend() {
-    logger.debug(`${LOGGER_CONTEXT}: suspend`, {}, logger.DebugContext.convo)
+    logger.debug(`${LOGGER_CONTEXT}: suspend`, {})
     this.dispatch({event: MessagesEventBusDispatchEvent.Suspend})
   }
 
   resume() {
-    logger.debug(`${LOGGER_CONTEXT}: resume`, {}, logger.DebugContext.convo)
+    logger.debug(`${LOGGER_CONTEXT}: resume`, {})
     this.dispatch({event: MessagesEventBusDispatchEvent.Resume})
   }
 
@@ -222,19 +223,15 @@ export class MessagesEventBus {
         break
     }
 
-    logger.debug(
-      `${LOGGER_CONTEXT}: dispatch '${action.event}'`,
-      {
-        id: this.id,
-        prev: prevStatus,
-        next: this.status,
-      },
-      logger.DebugContext.convo,
-    )
+    logger.debug(`${LOGGER_CONTEXT}: dispatch '${action.event}'`, {
+      id: this.id,
+      prev: prevStatus,
+      next: this.status,
+    })
   }
 
   private async init() {
-    logger.debug(`${LOGGER_CONTEXT}: init`, {}, logger.DebugContext.convo)
+    logger.debug(`${LOGGER_CONTEXT}: init`, {})
 
     try {
       const response = await networkRetry(2, () => {
@@ -258,7 +255,7 @@ export class MessagesEventBus {
       this.dispatch({event: MessagesEventBusDispatchEvent.Ready})
     } catch (e: any) {
       logger.error(e, {
-        context: `${LOGGER_CONTEXT}: init failed`,
+        message: `${LOGGER_CONTEXT}: init failed`,
       })
 
       this.dispatch({
@@ -327,7 +324,6 @@ export class MessagesEventBus {
     //       this.requestedPollIntervals.values(),
     //     ),
     //   },
-    //   logger.DebugContext.convo,
     // )
 
     try {
@@ -372,12 +368,12 @@ export class MessagesEventBus {
           this.emitter.emit('event', {type: 'logs', logs: batch})
         } catch (e: any) {
           logger.error(e, {
-            context: `${LOGGER_CONTEXT}: process latest events`,
+            message: `${LOGGER_CONTEXT}: process latest events`,
           })
         }
       }
     } catch (e: any) {
-      logger.error(e, {context: `${LOGGER_CONTEXT}: poll events failed`})
+      logger.error(e, {message: `${LOGGER_CONTEXT}: poll events failed`})
 
       this.dispatch({
         event: MessagesEventBusDispatchEvent.Error,