Skip to content

Commit

Permalink
Merge pull request #631 from Hexastack/fix/logger-2nd-attempt
Browse files Browse the repository at this point in the history
Fix/logger 2nd attempt
  • Loading branch information
marrouchi authored Jan 28, 2025
2 parents 6c5c430 + 1f81775 commit ad07884
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 131 deletions.
6 changes: 3 additions & 3 deletions api/src/analytics/services/bot-stats.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
* Copyright © 2025 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
Expand Down Expand Up @@ -127,10 +127,10 @@ export class BotStatsService extends BaseService<BotStats> {
try {
await this.updateOne(insight.id, { value: insight.value + 1 });
} catch (err) {
this.logger.error('Stats hook : Unable to update insight', err);
this.logger.error('Unable to update insight', err);
}
} catch (err) {
this.logger.error('Stats hook : Unable to find or create insight', err);
this.logger.error('Unable to find or create insight', err);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('AttachmentController', () => {

helperService = module.get<HelperService>(HelperService);
settingService = module.get<SettingService>(SettingService);
loggerService = module.get<LoggerService>(LoggerService);
loggerService = await module.resolve<LoggerService>(LoggerService);

helperService.register(
new LocalStorageHelper(settingService, helperService, loggerService),
Expand Down
4 changes: 2 additions & 2 deletions api/src/chat/controllers/message.controller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
* Copyright © 2025 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
Expand Down Expand Up @@ -173,7 +173,7 @@ export class MessageController extends BaseController<
success: true,
};
} catch (err) {
this.logger.debug('MessageController send : Unable to send message', err);
this.logger.debug('Unable to send message', err);
throw new BadRequestException(
'MessageController send : unable to send message',
);
Expand Down
2 changes: 1 addition & 1 deletion api/src/chat/services/block.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export class BlockService extends BaseService<
return e.entity === ev.entity;
});
} else {
this.logger.warn('Block Service : Unknown NLP match type', ev);
this.logger.warn('Unknown NLP match type', ev);
return false;
}
});
Expand Down
18 changes: 6 additions & 12 deletions api/src/chat/services/bot.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
* Copyright © 2025 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
Expand Down Expand Up @@ -62,10 +62,7 @@ export class BotService {
context = context || getDefaultConversationContext();
fallback = typeof fallback !== 'undefined' ? fallback : false;
const options = block.options;
this.logger.debug(
'Bot service : Sending message ... ',
event.getSenderForeignId(),
);
this.logger.debug('Sending message ... ', event.getSenderForeignId());
// Process message : Replace tokens with context data and then send the message
const recipient = event.getSender();
const envelope = await this.blockService.processMessage(
Expand Down Expand Up @@ -116,7 +113,7 @@ export class BotService {
assignTo,
);

this.logger.debug('Bot service : Assigned labels ', blockLabels);
this.logger.debug('Assigned labels ', blockLabels);
return response;
}

Expand Down Expand Up @@ -375,7 +372,7 @@ export class BotService {
);

this.logger.debug(
'Bot service : Started a new conversation with ',
'Started a new conversation with ',
subscriber.id,
block.name,
);
Expand All @@ -386,14 +383,11 @@ export class BotService {
false,
);
} catch (err) {
this.logger.error('Bot service : Unable to store context data!', err);
this.logger.error('Unable to store context data!', err);
this.eventEmitter.emit('hook:conversation:end', convo, true);
}
} catch (err) {
this.logger.error(
'Botservice : Unable to start a new conversation with ',
err,
);
this.logger.error('Unable to start a new conversation with ', err);
}
}

Expand Down
7 changes: 2 additions & 5 deletions api/src/chat/services/message.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
* Copyright © 2025 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
Expand Down Expand Up @@ -65,10 +65,7 @@ export class MessageService extends BaseService<
success: true,
});
} catch (e) {
this.logger.error(
'MessageController subscribe : Websocket subscription',
e,
);
this.logger.error('Websocket subscription', e);
throw new InternalServerErrorException(e);
}
}
Expand Down
4 changes: 1 addition & 3 deletions api/src/chat/services/subscriber.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ export class SubscriberService extends BaseService<
subscribe: Room.SUBSCRIBER,
});
} catch (e) {
this.logger.error(
'SubscriberController subscribe : Websocket subscription',
);
this.logger.error('Websocket subscription');
throw new InternalServerErrorException(e);
}
}
Expand Down
Loading

0 comments on commit ad07884

Please sign in to comment.