diff --git a/autotrader/autobot.py b/autotrader/autobot.py index 07c3f6d7..8e7a53e4 100644 --- a/autotrader/autobot.py +++ b/autotrader/autobot.py @@ -179,6 +179,7 @@ def __init__( "instrument": self.instrument, "broker": self._broker, "notifier": self._notifier, + "logger_kwargs": self._logger_kwargs, } # Instantiate Strategy diff --git a/autotrader/strategy.py b/autotrader/strategy.py index 64b2898d..1f843fe0 100644 --- a/autotrader/strategy.py +++ b/autotrader/strategy.py @@ -17,6 +17,7 @@ def __init__( instrument: str, broker: Broker, notifier: Notifier, + logger_kwargs: dict[str, any], *args, **kwargs ) -> None: @@ -36,6 +37,10 @@ def __init__( notifier : Notifier | None The notifier object. If notify is not set > 0, then this will be a NoneType object. + + logger_kwargs : dict[str, any] + The logger configuration for this instance of AutoTrader. This can be unpacked + into the get_logger() utility function when creating strategy loggers. """ super().__init__() diff --git a/autotrader/utilities.py b/autotrader/utilities.py index 5ebdbee6..5a02a082 100644 --- a/autotrader/utilities.py +++ b/autotrader/utilities.py @@ -411,7 +411,7 @@ def get_logger( # Check log directory exists if not os.path.exists(log_dir): os.mkdir(log_dir) - logfile_path = os.path.join(log_dir, f"{name}.log") + logfile_path = os.path.join(log_dir, f"{name.replace(os.sep, '_')}.log") fh = logging.FileHandler(logfile_path, mode="a") fh.setLevel(file_level) fh.setFormatter(logging.Formatter(CustomLoggingFormatter.default_fmt))