Ganga logging subsystem: Ganga.Utility.logging

Logging is based on standard python module logging.py: http://docs.python.org/lib/module-logging.html

Configuring loggers in a Ganga session

Logging level may be flexibly set for individual packages or groups of package in configuration file $HOME/.gangarc

In the example below all Ganga packages are in INFO level, except Ganga.Lib.LSF (DEBUG) and Ganga.Utility.Logging (ERROR). The verbosity of the messages is controlled by format_string and may have one of the values: TERSE NORMAL VERBOSE DEBUG

Ganga = INFO
Ganga.Lib.LSF = DEBUG
Ganga.Utility.Logging = ERROR
format_string = TERSE

Using loggers in your packages

The recommended way of using loggers in Ganga 4 development:

import Ganga.Utility.logging
logger = Ganga.Utility.logging.getLogger()
This creates a logger for your Ganga 4 package and it may be placed in one or many modules in that package. Each module will get the same logger instance. For example: if this code is placed in Ganga/Lib/LFS/whatever.py then the name of the logger will be Ganga.Lib.LFS

Sometimes it is desirable to create logger for individual module (for example Ganga.Lib.LFS.whatever). You can do this like this:

import Ganga.Utility.logging
logger = Ganga.Utility.logging.getLogger(modulename=1)

You can also give any name you like to your logger but it MUST start with string 'Ganga.'

import Ganga.Utility.logging
logger = Ganga.Utility.logging.getLogger("Ganga.special_logger")

Note: Ganga.Utility.logging just makes it easier to configure standard loggers to use within Ganga packages. If you use Ganga.Utility.logging in an executable script then the default name of your logger will not start with 'Ganga.' and therefore you will not be able to control it with the Ganga configuration file.

-- JakubMoscicki - 18-Feb-2011

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r2 - 2011-09-14 - MichaelJohnKenyonExCern
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    ArdaGrid All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2023 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback