lib.log
- class lib.log.Log(smarthome, name, mapping, maxlen=40, handler=None)[Quellcode]
Bases:
collections.deque
- add(entry)[Quellcode]
Adds a log entry to the memory log. If the log already has reached the maximum length, the oldest entry is removed from the log automatically.
- clean(dt)[Quellcode]
Assuming dt to be a datetime: remove all entries that are smaller or equal to this given datetime from the right side of the queue
- export(number)[Quellcode]
Returns the newest entries of the log and prepares them with the mapping
- Parameter
number – Number of entries to return
- Rückgabe
List of log entries
- last(number)[Quellcode]
Returns the newest entries of the log
- Parameter
number – Number of entries to return
- Rückgabe
List of log entries
- class lib.log.Logs(sh)[Quellcode]
Bases:
object
- add_log(name, log)[Quellcode]
Adds a log (object) to the list of memory logs
- Parameter
name – Name of log
log – Log object
- add_logging_level(description, value)[Quellcode]
Adds a new Logging level to the standard python logging
- Parameter
description (string) – appearance within logs SYSINFO
value (int) – numeric value for the logging level
tocall (String, optional, if not given description will be used with lower case) – function name to call for a log with the given level
no error checking is performed here for typos, already existing levels or functions
- configure_logging(config_dict, config_filename='logging.yaml')[Quellcode]
- initMemLog()[Quellcode]
This function initializes all needed datastructures to use the ‚env.core.log‘ mem-logger and the (old) memlog plugin
It adds the handler log_mem (based on the custom lib.log.ShngMemLogHandler) to the root logger It logs all WARNINGS from all (old) mem-loggers to the root Logger
- return_logs()[Quellcode]
Function to the list of memory logs
- Rückgabe
List of logs
- Rückgabetyp
list
- root_handler_name = ''
- class lib.log.ShngMemLogHandler(logname='undefined', maxlen=35, level=0)[Quellcode]
Bases:
logging.StreamHandler
LogHandler used by MemLog
- emit(record)[Quellcode]
Emit a record.
If a formatter is specified, it is used to format the record. The record is then written to the stream with a trailing newline. If exception information is present, it is formatted using traceback.print_exception and appended to the stream. If the stream has an ‚encoding‘ attribute, it is used to determine how to do the output to the stream.
- class lib.log.ShngTimedRotatingFileHandler(filename, when='h', interval=1, backupCount=0, encoding=None, delay=False, utc=False, atTime=None)[Quellcode]
Bases:
logging.handlers.TimedRotatingFileHandler
TimedRotatingFilehandler with a different naming scheme for rotated files
- doRollover()[Quellcode]
do a rollover; in this case, a date/time stamp is appended to the filename when the rollover happens. However, you want the file to be named for the start of the interval, not the current time. If there is a backup count, then we have to get a list of matching filenames, sort them and remove the one with the oldest suffix.
- getFilesToDelete()[Quellcode]
Determine the files to delete when rolling over.
More specific than the earlier method, which just used glob.glob().