generated from neutrons/python_project_template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b62984
commit df55890
Showing
4 changed files
with
90 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Logging | ||
========= | ||
|
||
GARNET uses the Mantid logging framework. | ||
|
||
Mantid provides 7 built-in logging levels: | ||
- Debug | ||
- Information | ||
- Notice | ||
- Warning | ||
- Error | ||
- Critical | ||
- Fatal | ||
|
||
Mantid convention reserves debug for developers and the rest available to the user. | ||
The information level should be used by default. | ||
|
||
Users can configure the logging framework in the GARNET configuration file. | ||
|
||
More information is available in the `Mantid logging documentation <https://developer.mantidproject.org/Logging.html>`_. | ||
|
||
|
||
Logging in Python | ||
------------------- | ||
Developers can access the logger with | ||
|
||
.. code-block:: python | ||
from mantid.kernel import logger | ||
logger.information("This logs to the information level...") | ||
logger.error("...and this to the error level.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
logging.loggers.root.level = information | ||
logging.loggers.root.channel.class = SplitterChannel | ||
logging.loggers.root.channel.channel1 = consoleChannel | ||
logging.channels.consoleChannel.class = ConsoleChannel | ||
logging.channels.consoleChannel.formatter = f1 | ||
logging.formatters.f1.class = PatternFormatter | ||
logging.formatters.f1.pattern = %s-[%p] %t | ||
logging.formatters.f1.times = local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
""" | ||
GARNET logging framework for models | ||
""" | ||
|
||
from mantid.kernel import logger | ||
from mantid.kernel import ConfigService | ||
|
||
|
||
from configobj import ConfigObj | ||
|
||
|
||
|
||
def init_logging(): | ||
""" | ||
Pass logging configurations from the conf file | ||
""" | ||
|
||
conf_svc = ConfigService.Instance() | ||
|
||
LOGGING_CONF = "logging.conf" | ||
conf = ConfigObj(LOGGING_CONF) | ||
|
||
for option in conf: | ||
if 'logging' in option: | ||
conf_svc.setString(option, conf[option]) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|