Initialize streamhandler early to have it apply to all logs
This commit is contained in:
parent
cdfcdb86c9
commit
c4f78203ab
@ -48,6 +48,7 @@ def setup_logging_pre() -> None:
|
|||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=logging.INFO,
|
level=logging.INFO,
|
||||||
format=LOGFORMAT,
|
format=LOGFORMAT,
|
||||||
|
handlers=[logging.StreamHandler(sys.stderr)]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -61,8 +62,6 @@ def setup_logging(config: Dict[str, Any]) -> None:
|
|||||||
|
|
||||||
logfile = config.get('logfile')
|
logfile = config.get('logfile')
|
||||||
|
|
||||||
logging.root.addHandler(logging.StreamHandler(sys.stderr))
|
|
||||||
|
|
||||||
if logfile:
|
if logfile:
|
||||||
s = logfile.split(':')
|
s = logfile.split(':')
|
||||||
if s[0] == 'syslog':
|
if s[0] == 'syslog':
|
||||||
|
@ -21,7 +21,7 @@ from freqtrade.configuration.deprecated_settings import (
|
|||||||
from freqtrade.configuration.load_config import load_config_file, log_config_error_range
|
from freqtrade.configuration.load_config import load_config_file, log_config_error_range
|
||||||
from freqtrade.constants import DEFAULT_DB_DRYRUN_URL, DEFAULT_DB_PROD_URL
|
from freqtrade.constants import DEFAULT_DB_DRYRUN_URL, DEFAULT_DB_PROD_URL
|
||||||
from freqtrade.exceptions import OperationalException
|
from freqtrade.exceptions import OperationalException
|
||||||
from freqtrade.loggers import _set_loggers, setup_logging
|
from freqtrade.loggers import _set_loggers, setup_logging, setup_logging_pre
|
||||||
from freqtrade.state import RunMode
|
from freqtrade.state import RunMode
|
||||||
from tests.conftest import (log_has, log_has_re,
|
from tests.conftest import (log_has, log_has_re,
|
||||||
patched_configuration_load_config_file)
|
patched_configuration_load_config_file)
|
||||||
@ -674,6 +674,7 @@ def test_set_loggers_syslog(mocker):
|
|||||||
'logfile': 'syslog:/dev/log',
|
'logfile': 'syslog:/dev/log',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setup_logging_pre()
|
||||||
setup_logging(config)
|
setup_logging(config)
|
||||||
assert len(logger.handlers) == 3
|
assert len(logger.handlers) == 3
|
||||||
assert [x for x in logger.handlers if type(x) == logging.handlers.SysLogHandler]
|
assert [x for x in logger.handlers if type(x) == logging.handlers.SysLogHandler]
|
||||||
|
Loading…
Reference in New Issue
Block a user