Package entropy :: Module misc :: Class LogFile

Class LogFile

source code

Entropy simple logging interface, works as file object

Instance Methods
 
__init__(self, level=None, filename=None, header='[LOG]')
LogFile constructor.
source code
 
__enter__(self)
Just return self, configuration is done in __init__
source code
 
__exit__(self, exc_type, exc_value, traceback)
Make sure any resource is closed.
source code
 
fileno(self) source code
 
isatty(self) source code
 
flush(self)
Flush log buffer
source code
 
close(self)
Close log file
source code
 
log(self, messagetype, level, message)
This is the effective function that LogFile consumers should use.
source code
 
write(self, mystr)
File object method, write log message to file using the default handler set (LogFile.default_handler is the default).
source code
 
writelines(self, lst)
File object method, write log message strings to file using the default handler set (LogFile.default_handler is the default).
source code
Class Variables
  LEVELS = {'critical': 50, 'debug': 10, 'error': 40, 'info': 20...
  LOG_FORMAT = '%(asctime)s %(levelname)s: %(message)s'
  DATE_FORMAT = '[%H:%M:%S %d/%m/%Y %Z]'
Method Details

__init__(self, level=None, filename=None, header='[LOG]')
(Constructor)

source code 

LogFile constructor.

Parameters:
  • level (int) - any valid Entropy log level id (0, 1, 2). 0: error logging, 1: normal logging, 2: debug logging
  • filename (string) - log file path
  • header (string) - log line header

log(self, messagetype, level, message)

source code 

This is the effective function that LogFile consumers should use.

Parameters:
  • messagetype (string) - message type (or tag)
  • level (int) - minimum logging threshold which should trigger the effective write
  • message (string) - log message

write(self, mystr)

source code 

File object method, write log message to file using the default handler set (LogFile.default_handler is the default).

Parameters:
  • mystr (string) - log string to write

writelines(self, lst)

source code 

File object method, write log message strings to file using the default handler set (LogFile.default_handler is the default).

Parameters:
  • lst (list) - list of strings to write

Class Variable Details

LEVELS

Value:
{'critical': 50, 'debug': 10, 'error': 40, 'info': 20, 'warning': 30}