Add option to log to stderr
This commit is contained in:
parent
17fce00a5e
commit
255206720f
@ -9,7 +9,8 @@ from typing import Any, Dict, List, Optional
|
|||||||
from freqtrade import constants
|
from freqtrade import constants
|
||||||
from freqtrade.configuration.cli_options import AVAILABLE_CLI_OPTIONS
|
from freqtrade.configuration.cli_options import AVAILABLE_CLI_OPTIONS
|
||||||
|
|
||||||
ARGS_COMMON = ["verbosity", "logfile", "version", "config", "datadir", "user_data_dir"]
|
ARGS_COMMON = ["verbosity", "log_to_stderr", "logfile", "version", "config", "datadir",
|
||||||
|
"user_data_dir"]
|
||||||
|
|
||||||
ARGS_STRATEGY = ["strategy", "strategy_path"]
|
ARGS_STRATEGY = ["strategy", "strategy_path"]
|
||||||
|
|
||||||
|
@ -34,6 +34,12 @@ AVAILABLE_CLI_OPTIONS = {
|
|||||||
action='count',
|
action='count',
|
||||||
default=0,
|
default=0,
|
||||||
),
|
),
|
||||||
|
"log_to_stderr": Arg(
|
||||||
|
'-E', '--stderr',
|
||||||
|
help='Force log messages to be printed to stderr instead of stdout.',
|
||||||
|
action='store_true',
|
||||||
|
default=False,
|
||||||
|
),
|
||||||
"logfile": Arg(
|
"logfile": Arg(
|
||||||
'--logfile',
|
'--logfile',
|
||||||
help='Log to the file specified.',
|
help='Log to the file specified.',
|
||||||
|
@ -125,6 +125,8 @@ class Configuration:
|
|||||||
# Log level
|
# Log level
|
||||||
config.update({'verbosity': self.args.get("verbosity", 0)})
|
config.update({'verbosity': self.args.get("verbosity", 0)})
|
||||||
|
|
||||||
|
config.update({'log_to_stderr': self.args.get("log_to_stderr", False)})
|
||||||
|
|
||||||
if 'logfile' in self.args and self.args["logfile"]:
|
if 'logfile' in self.args and self.args["logfile"]:
|
||||||
config.update({'logfile': self.args["logfile"]})
|
config.update({'logfile': self.args["logfile"]})
|
||||||
|
|
||||||
|
@ -33,8 +33,9 @@ def setup_logging(config: Dict[str, Any]) -> None:
|
|||||||
# Log level
|
# Log level
|
||||||
verbosity = config['verbosity']
|
verbosity = config['verbosity']
|
||||||
|
|
||||||
# Log to stdout, not stderr
|
# By default, log to stdout, not stderr
|
||||||
log_handlers: List[logging.Handler] = [logging.StreamHandler(sys.stdout)]
|
stream = sys.stderr if config['log_to_stderr'] else sys.stdout
|
||||||
|
log_handlers: List[logging.Handler] = [logging.StreamHandler(stream)]
|
||||||
|
|
||||||
if config.get('logfile'):
|
if config.get('logfile'):
|
||||||
log_handlers.append(RotatingFileHandler(config['logfile'],
|
log_handlers.append(RotatingFileHandler(config['logfile'],
|
||||||
|
Loading…
Reference in New Issue
Block a user