11import { PUBLIC_DOMAIN } from "@/config" ;
2+ import { logger } from "@/utils/logger" ;
23import axios from "axios" ;
34import { Request , Response } from "express" ;
45import { BaseChannel } from "./base.channel" ;
@@ -36,9 +37,9 @@ export class LineChannel extends BaseChannel {
3637 'Content-Type' : 'application/json' ,
3738 } ,
3839 } ) ;
39- console . log ( `[LIN] Registered webhook for ${ this . channelType } - ${ this . contactName } ${ this . contactId } ` ) ;
40+ logger . info ( `[LIN] Registered webhook for ${ this . channelType } - ${ this . contactName } ${ this . contactId } ` ) ;
4041 } catch ( e ) {
41- console . log ( `[LIN] Can not register webhook for ${ this . channelType } - ${ this . contactName } ${ this . contactId } ` ) ;
42+ logger . info ( `[LIN] Can not register webhook for ${ this . channelType } - ${ this . contactName } ${ this . contactId } ` ) ;
4243
4344 }
4445 }
@@ -56,7 +57,7 @@ export class LineChannel extends BaseChannel {
5657
5758 return data . userId ;
5859 } catch ( e ) {
59- console . log ( `[LIN] Can not get user ID for ${ this . channelType } - ${ this . contactName } ${ this . contactId } ` ) ;
60+ logger . info ( `[LIN] Can not get user ID for ${ this . channelType } - ${ this . contactName } ${ this . contactId } ` ) ;
6061 }
6162 }
6263
@@ -72,12 +73,8 @@ export class LineChannel extends BaseChannel {
7273 const { message, source } = events [ 0 ] ;
7374
7475 await this . postMessageToBot ( { userId : source . userId , message : message . text , data : null } ) ;
75-
76- console . log ( `[LIN] Sent message: ${ message . text } from ${ lineUserId } to Bot` ) ;
7776 }
78- } catch ( e ) {
79- console . log ( `[LIN] ${ this . contactId } Can not send message to Bot - ${ e . message } ` ) ;
80- }
77+ } catch ( e ) { }
8178 }
8279
8380 public async sendMessageToUser ( { userId, text } ) {
@@ -96,8 +93,10 @@ export class LineChannel extends BaseChannel {
9693 Authorization : 'Bearer ' + this . pageToken ,
9794 } ,
9895 } )
96+
97+ logger . info ( `[LIN] Bot send message to User ${ lineUserId } - Message: ${ text } ` ) ;
9998 } catch ( e ) {
100- console . log ( `[LIN] Send message to User ${ lineUserId } failed` ) ;
99+ logger . info ( `[LIN] Bot send message to User ${ lineUserId } failed - Error: ${ e . message } ` ) ;
101100 }
102101 }
103102}
0 commit comments