Skip to content

Commit

Permalink
Update chatbot log to retain usual formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed Dec 15, 2023
1 parent 23019db commit a324363
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions chatbot_core/chatbot_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import random
import time
import inspect

from abc import ABC, abstractmethod
from queue import Queue
Expand Down Expand Up @@ -49,6 +50,13 @@ def log(self):
if not self.__log:
# Copy log to support multiple bots in thread with different names
self.__log = init_log().create_logger(self._bot_id)
name = self._bot_id
stack = inspect.stack()
record = stack[2]
mod = inspect.getmodule(record[0])
module_name = mod.__name__ if mod else ''
name += module_name + ':' + record[3] + ':' + str(record[2])
self.__log.name = name
return self.__log

@abstractmethod
Expand Down

0 comments on commit a324363

Please sign in to comment.