RAVE
Lib.rave_pgf_logger Namespace Reference

Classes

class  LogRecordSocketReceiver
 Simple TCP socket-based logging receiver suitable for testing, and maybe a little more. More...
 
class  LogRecordStreamHandler
 Handler for a streaming logging request. More...
 
class  rave_pgf_logger_server
 

Functions

 init_logger (logger, level=LOGLEVEL, logfile=LOGFILE)
 Initializes the system logger.
 
 log (logger, level, msg)
 Locks, logs, and unlocks, with rudimentary level filtering.
 
 rave_pgf_logger_client (host=PGF_HOST, port=LOGPORT, level=LOGLEVEL)
 Client logger.
 
 rave_pgf_syslog_client (name=LOGID, address=SYSLOG, facility=LOGFACILITY, level=LOGLEVEL)
 SysLog client.
 
 rave_pgf_stdout_client (name="RAVE-STDOUT", level=LOGLEVEL)
 stdout client.
 
 rave_pgf_logfile_client (name="RAVE-LOGFILE", level=LOGLEVEL, logfile=LOGFILE, logfilesize=LOGFILESIZE, nrlogfiles=LOGFILES)
 
 create_logger (level=LOGLEVEL, name=None)
 

Variables

dict LOGLEVELS
 
 tempdir
 
str prog = "rave_pgf_logger_server"
 
str usage = "usage: %s start|stop|status|restart|fg" % prog
 
 ARG = sys.argv[1].lower()
 
 this = rave_pgf_logger_server()
 
 myLogger = rave_pgf_syslog_client()
 

Detailed Description

Copyright (C) 2010- Swedish Meteorological and Hydrological Institute (SMHI)

This file is part of RAVE.

RAVE is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

RAVE is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with RAVE.  If not, see <http://www.gnu.org/licenses/>.

Function Documentation

◆ init_logger()

Lib.rave_pgf_logger.init_logger ( logger,
level = LOGLEVEL,
logfile = LOGFILE )

Initializes the system logger.

Parameters
loggeran instance returned by logging.getLogger()
levelint log level

◆ log()

Lib.rave_pgf_logger.log ( logger,
level,
msg )

Locks, logs, and unlocks, with rudimentary level filtering.

Parameters
loggerthe logger object initialized with init_logger()
levelstring log level
msgstring log message

◆ rave_pgf_logger_client()

Lib.rave_pgf_logger.rave_pgf_logger_client ( host = PGF_HOST,
port = LOGPORT,
level = LOGLEVEL )

Client logger.

Clients can be created even when the server isn't running. They will succeed in connecting and logging when the server starts, even though messages will be lost before this is done. The only time this could happen is when the PGF and logger servers are initializing, and the client loggers in the PGF server send messages before the logger server is ready, which is highly unlikely.

Parameters
hostURI to the host for this server.
portint port number to the host for this server.
levelstring log level
Returns
logging.getLogger client

◆ rave_pgf_stdout_client()

Lib.rave_pgf_logger.rave_pgf_stdout_client ( name = "RAVE-STDOUT",
level = LOGLEVEL )

stdout client.

Parameters
levelstring log level
Returns
logging.getLogger client that your application will use to send messages to stdout

◆ rave_pgf_syslog_client()

Lib.rave_pgf_logger.rave_pgf_syslog_client ( name = LOGID,
address = SYSLOG,
facility = LOGFACILITY,
level = LOGLEVEL )

SysLog client.

It is up to the user to figure out how to sort/filter syslog messages. The level of the messages actually appearing in syslog will be determined by the level set by your host, and changing this may require root access.

Parameters
namestring logger identifier. This will look up a logger that is already initialized after it has been initialized the first time, normally when the PGF server starts.
addresstuple containing (string, int) for (host, port) or the device file containing the socket used for syslog.
facilitystring representing the syslog facility
levelstring log level
Returns
logging.getLogger client that your application will use to send messages to syslog

Variable Documentation

◆ LOGLEVELS

dict Lib.rave_pgf_logger.LOGLEVELS
Initial value:
1= {"notset" : logging.NOTSET,
2 "debug" : logging.DEBUG,
3 "info" : logging.INFO,
4 "warn" : logging.WARN,
5 "warning" : logging.WARNING,
6 "error" : logging.ERROR,
7 "critical" : logging.CRITICAL,
8 "fatal" : logging.FATAL}