New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a logging file #28

Closed
uvchik opened this Issue Dec 10, 2015 · 1 comment

Comments

Projects
None yet
1 participant
@uvchik
Copy link
Member

uvchik commented Dec 10, 2015

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.

@uvchik uvchik added the enhancement label Dec 10, 2015

@uvchik uvchik self-assigned this Dec 10, 2015

@uvchik uvchik added this to the December 2015 release milestone Dec 14, 2015

@uvchik

This comment has been minimized.

Copy link
Member Author

uvchik commented Dec 22, 2015

No feedback? So I will close the issue and use the logger. Reopen if anything is unclear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment