HWRF
trunk@4391
|
Configures logging. More...
Configures logging.
This module configures logging for stdout, stderr and the jlogfile. It also contains the jlogger, a logger.Logger object that is used to log directly to the jlogfile, and jlogdomain: a string name of the logger domain for the jlogfile.
Classes | |
class | JLogFormatter |
This subclass of MasterLogFormatter does not include exception information in the log file. More... | |
class | JLogHandler |
Custom LogHandler for the jlogfile. More... | |
class | MasterLogFormatter |
This is a custom log formatter that inserts the thread or process (logthread) that generated the log message. More... | |
class | MasterLogHandler |
Custom LogHandler for the master process of a multi-process job. More... | |
class | ThreadLogger |
Custom logging.Logger that inserts thread information. More... | |
Functions | |
def | postmsg (message) |
Sends the message to the jlogfile logging stream at level INFO. More... | |
def | set_jlogfile (filename) |
Tells the jlogger to log to the specified file instead of the current jlogfile. More... | |
def | stdout_is_stderr () |
Returns True if it can determine that stdout and stderr are the same file or terminal. More... | |
def | mpi_redirect |
Used to split to multiple logging streams. More... | |
def | configureLogging |
Configures log output to stderr, stdout and the jlogfile. More... | |
Variables | |
list | __all__ |
Symbols epxorted by "from produtil.log import *". More... | |
string | logthread = '' |
string for log messages to indicate thread number/name | |
string | jlogdomain = 'jlog' |
Logging domain for the jlogfile. | |
tuple | jlogger = logging.getLogger(jlogdomain) |
A logging.Logger for the jlogdomain. | |
jloghandler = None | |
A logging.LogHandler for the jlogger. | |
def produtil.log.configureLogging | ( | jlogfile = None , |
|
level = logging.INFO , |
|||
jloglevel = logging.INFO , |
|||
japplevel = logging.ERROR , |
|||
eloglevel = logging.WARNING , |
|||
ologlevel = logging.NOTSET , |
|||
thread_logger = False |
|||
) |
Configures log output to stderr, stdout and the jlogfile.
Configures log file locations and logging levels for all streams.
jlogfile | path to the jlogfile. Default: use os.environ('jlogfile') if set. Otherwise, stderr. |
level | minimum logging level globally. Set to INFO by default. Change this to logging.DEBUG if you're debugging the program. |
jloglevel | minimum logging level to send to jlogfile |
japplevel | minimum logging level to send to jlogfile from all domains except that specified in jlogdomain. Be careful when changing this as it logs directly to the WCOSS-wide jlogfile in operations. |
eloglevel | minimum logging level to send to stderr from ALL logs Set to None to disable stderr logging |
ologlevel | minimum logging level to send to stdout from ALL logs Default: logging.NOTSET (no filtering) Set to None to disable stdout logging. |
thread_logger | True to include the thread name in log messages. |
Definition at line 310 of file log.py.
Referenced by produtil.log.mpi_redirect(), and produtil.setup.setup().
def produtil.log.mpi_redirect | ( | threadname, | |
stderrfile, | |||
stdoutfile, | |||
masterlevel = logging.WARNING , |
|||
openmode = None , |
|||
logger = None |
|||
) |
Used to split to multiple logging streams.
When the Python script splits itself into multiple processes via MPI, this function is called to redirect stdout to stdoutfile, stderr to stderrfile, and produce a new logging stream to the original stderr, with a logging level set to masterlevel. That new logging stream is called the "master log" and will receive any messages at level masterlevel or higher, and any messages sent to the jlogdomain.
This can also be used to redirect ONLY stdout, in which case no master logging stream is set up. That is requested by stderrfile=None.
threadname | the name of this process for logging purposes |
stderrfile | file to receive stderr |
stdoutfile | file to receive stdout |
masterlevel | log level to send to master log stream |
openmode | integer mode to use when opening files |
logger | a logging.Logger for logging errors while splitting the log stream. |
Definition at line 226 of file log.py.
Referenced by produtil.log.JLogHandler.set_jlogfile(), and scripts.exhwrf_products.slave_main().
def produtil.log.postmsg | ( | message | ) |
Sends the message to the jlogfile logging stream at level INFO.
This is identical to:
message | the message to log. |
Definition at line 46 of file log.py.
Referenced by scripts.exhwrf_forecast.doit(), hwrf.launcher.HWRFLauncher.gen_vitals(), scripts.exhwrf_ocean_init.main(), scripts.exhwrf_launch.main(), and hwrf.launcher.HWRFLauncher.tcautoseed().
def produtil.log.set_jlogfile | ( | filename | ) |
def produtil.log.stdout_is_stderr | ( | ) |
Returns True if it can determine that stdout and stderr are the same file or terminal.
Returns False if it can determine they are not, or if the result is inconclusive.
Definition at line 119 of file log.py.
Referenced by produtil.log.configureLogging().