Skip to content

Commit

Permalink
create new logger instead of using global root logger
Browse files Browse the repository at this point in the history
  • Loading branch information
adbenitez committed Mar 7, 2024
1 parent c8e6340 commit da144e3
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions deltabot_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def get_account(self, rpc: Rpc, addr: str) -> int:
for accid in rpc.get_all_account_ids():
if addr == self.get_address(rpc, accid):
return accid

return 0

def get_address(self, rpc: Rpc, accid: int) -> str:
Expand All @@ -181,16 +182,13 @@ def start(self) -> None:
self.init_parser()
args = self._parser.parse_args()
log_level = int(getattr(logging, args.logging.upper()))
logging.basicConfig(
level=log_level,
format="%(message)s",
handlers=[RichHandler(show_path=False)],
)
logger = logging.Logger(self.app_name, log_level)
logger.handlers = [RichHandler(show_path=False, omit_repeated_times=False)]
accounts_dir = self.get_accounts_dir(args)

kwargs = {"stderr": subprocess.DEVNULL} if log_level > logging.DEBUG else {}
with Rpc(accounts_dir=accounts_dir, **kwargs) as rpc:
self._bot = Bot(rpc, self._hooks)
self._bot = Bot(rpc, self._hooks, logger)
self._on_init(self._bot, args)

core_version = rpc.get_system_info().deltachat_core_version
Expand Down

0 comments on commit da144e3

Please sign in to comment.