nautechsystems / nautilus_trader

A high-performance algorithmic trading platform and event-driven backtester

Home Page:https://nautilustrader.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Logger Output Not Printing to Console After Commit 120bc0e

rsmb7z opened this issue · comments

Bug Report

Expected Behavior

Following code used to print the output logs to console however since 120bc0e it is no longer working.

from nautilus_trader.common.logging import LoggerAdapter
from nautilus_trader.common.logging import Logger
from nautilus_trader.common.clock import LiveClock
logger = Logger(clock=LiveClock())
log = LoggerAdapter(
 component_name="TEST-0",
 logger=logger,
)
log.error("This should print the error.")
log.warning("This should print the warning.")
log.info("This should print the info.")

Actual Behavior

Logs are not printed to console.

Steps to Reproduce the Problem

Simply excute the above code which doesn't result in any error but also doesn't print any logs to console.

Specifications

  • OS platform: Windows
  • Python version: 3.11.6
  • nautilus_trader version: develop latest

Noticed odd thing though, when you run the backtest first and execute above code in same console, output works as expected but doesn't when excuted in new console.

@cjdsellers it worked by using init_logging as you suggested. This issue may be closed.

Hi @rsmb7z

This is now repaired on develop branch.

It's now possible to use a logger in isolation of the NautilusKernel, and the lower level Rust logging system will be initialized as you would expect.

You also don't need to pass a live clock anymore if you simply want a basic logger, this will work as you would expect:

logger = Logger()