Skip to content
Snippets Groups Projects

Introduced log file option

Merged Adham Hashibon requested to merge add-logging-file into master
6 files
+ 42
25
Compare changes
  • Side-by-side
  • Inline
Files
6
import logging
import click
from ..bdss_application import BDSSApplication
@@ -10,12 +11,26 @@ push_exception_handler(reraise_exceptions=True)
@click.command()
@click.option("--evaluate", is_flag=True)
@click.option("--logfile",
type=click.Path(exists=False),
help="If specified, the log filename. "
" If unspecified, the log will be written to stdout.")
@click.argument('workflow_filepath', type=click.Path(exists=True))
def run(evaluate, workflow_filepath):
def run(evaluate, logfile, workflow_filepath):
application = BDSSApplication(
evaluate=evaluate,
workflow_filepath=workflow_filepath
)
logging_config = {}
if logfile is not None:
logging_config["filename"] = logfile
application.run()
logging.basicConfig(**logging_config)
log = logging.getLogger(__name__)
try:
application = BDSSApplication(
evaluate=evaluate,
workflow_filepath=workflow_filepath
)
application.run()
except Exception as e:
log.exception(e)
Loading