Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Creating a logging file #28
With commit 37afe31 one can use a helping function to initialise a logger within oemof.
Just import the logger module and initialise the logger at the very beginning of your app.
# Import logging module from oemof.tools import logger # initialise the logger logger.define_logging()
Now everything higher than info will be displayed on the screen but everything (including debug) will be written to a logfile in the folder: ~/.oemof/log_files/
Of course you are able to customise this behaviour. For example if want just warnings and errors but no infos on the screen.
The screen output looks like this now:
11:40:24-INFO-Path for logging: /home/uwe/.oemof/log_files 11:40:24-INFO-Used oemof version: 18345077 @ features/two_region_example 11:40:25-INFO-Processing region: Landkreis Wittenberg (LanWit) 11:40:26-WARNING-Something odd happened...
The file output looks like this:
2015-12-10 11:41:14,628 - INFO - logger - Path for logging: /home/uwe/.oemof/log_files 2015-12-10 11:41:14,628 - INFO - logger - Used oemof version: 18345077 @ features/two_region_example 2015-12-10 11:41:14,693 - DEBUG - tools - Getting polygon from DB 2015-12-10 11:41:14,694 - INFO - two_regions_example - Processing region: Landkreis Wittenberg (LanWit) 2015-12-10 11:41:15,591 - DEBUG - models - Retrieving cp values from cp_values.hf5 2015-12-10 11:41:16,987 - WARNING - models - Something odd happened...
@oemof/oemof-main : Do we agree that we want to use logging messages within the code? I like the fact that you have a protocol in a file. This can help a lot while debugging. But than we need meaningful logging messages.