glusto.loggable module¶
All things logging.
Note
Loggable is inherited by the Glusto class and not designed to be instantiated.
-
class
glusto.loggable.
Loggable
¶ Bases:
object
The class providing logging functionality.
-
handler_counter
= 1¶
-
classmethod
create_log
(name='glustolog', filename='/tmp/glusto.log', level='DEBUG', log_format=None, allow_multiple=False)¶ Creates a log object using the Python “logging” module.
Parameters: - name (optional[str]) – The reference name for the logging object. Defaults to “glustolog”.
- filename (optional[str]) – Fully-qualified path and filename. Defaults to “/tmp/glusto.log”.
- level (optional[str]) – The minimum log level. Defaults to “INFO”.
- allow_multiple (bool) – Can multiple logfiles exist? Tells method whether to create a new handler or wipe existing before creating a new handler.
Returns: A logging object.
-
classmethod
add_log
(logobj, filename='/tmp/glusto.log', level='INFO', log_format=None)¶ Add a logfile to the logobj
Parameters: - logobj (object) – A logging object.
- filename (optional[str]) – Fully-qualified path and filename. Defaults to “/tmp/glusto.log”.
- level (optional[str]) – The minimum log level. Defaults to “INFO”.
-
classmethod
remove_log
(logobj, name=None)¶ Remove a log handler from a logger object.
Parameters: - logobj (object) – A logging object.
- name (optional[str]) – The name of the log handler to remove. If None, will remove all log handlers from the logger.
-
classmethod
show_logs
(logobj)¶ Show a list of log handlers attached to a logging object
Parameters: logobj (object) – A logging object.
-
classmethod
disable_log_levels
(level)¶ Disable level (and lower) across all logs and handlers. Handy if a method continually spams the logs. Use reset_log_level() to return to normal logging.
Note
See Python logging module docs for more information.
Parameters: level (str) – String name for the top log level to disable. Returns: Nothing
-
classmethod
reset_log_levels
()¶ Reset logs to current handler levels. Convenience method to undo disable_log_level()
Parameters: None – Returns: Nothing
-
classmethod
set_log_level
(log_name, handler_name, level)¶ Set the log level for a specific handler. Use show_logs() to get the list of log and handler names.
Parameters: - log_name (str) – The name of the log.
- handler_name (str) – The name of the specific log handler.
- level (str) – The string representation of the log level.
Returns: Nothing
-
classmethod
set_log_filename
(log_name, handler_name, filename)¶ Change the logfile name for a specific handler. Use show_logs() to get the list of log and handler names.
Parameters: - log_name (str) – The name of the log.
- handler_name (str) – The name of the specific log handler.
- filename (str) – The path/filename to log to.
Returns: Nothing
Note
Nothing in logging docs mentions this method (close and set baseFilename) over removing the handler and creating a new handler with the new filename. Research and correct if needed. Caveat emptor.
-
classmethod
clear_log
(log_name, handler_name)¶ Empties an existing log file
Parameters: - log_name (str) – The name of the log.
- handler_name (str) – The name of the specific log handler.
Returns: Nothing
-