pysumo.logger package

Module contents

The pySUMO logging interface.

This package contains 2 modules:

  • infolog: A singleton called from the entry point to initialize the python logging framework and set the loglevel.
  • actionlog: Stores a list of all write operations on the Ontology and provides undo and redo functionality.

Submodules

pysumo.logger.actionlog module

!include ./UML/pysumo/logger/Actionlog.iuml


The pySUMO action log handler. This module handles undo and redo operations.

This module contains:

  • ActionLog: The action log handler.
  • LogIO: The action log io interface.
class pysumo.logger.actionlog.ActionLog(name, path=None)[source]

The pySUMO action log. The SyntaxController queues a new log entry before every operation that makes changes to an Ontology, if the change is successful it OKs the entry in the log queue and the entry is written out. Log entries that are not OKed time out and are removed from the queue.

Variables:

  • log_io: The io object for this log.
  • queue: A queue of actions that have not yet successfully completed.
  • actionlog: A list of actions that have completed successfully.
  • redolog: A list of actions that have been undone successfully.
  • current: The current state of the Ontology.

Methods:

  • queue_log: Create a log entry and append it to the log queue.
  • ok_log_item: Move log entry from log queue to actual log.
  • undo: Undoes the last action.
  • redo: Redoes the last undone action.
ok_log_item(log_queue_ok_num)[source]

Appends the item in self.queue with log_queue_ok_num to self.actionlog and calls self.log_io.append_write_queue on it.

Args:

  • log_queue_ok_num: the number of the queue item to okay

Raises:

  • KeyError
queue_log(data)[source]

Create a log entry and queue it for addition to self.actionlog.

Args:

  • data: the data to be placed in the log

Returns:

  • int. The log_queue_ok_num
redo()[source]

Redoes the last undone action, appends it to self.undolog and removes it from self.redolog.

undo()[source]

Undoes the last action and appends it to self.redolog.

class pysumo.logger.actionlog.LogIO(name, path='/home/docs/.pysumo/actionlog')[source]

The IO interface for the pySUMO action log. This class provides a storage backend for the Action Log. Entries in the write queue are written to disk after a timeout, or when the write queue reaches a maximum size.

Variables:

  • default_path: The default log path.
  • timeout: The time period after which if no new packets have entered the queue, the queue is flushed.
  • max_size: The maximum number of actions in the write queue after which when another packet enters the queue, the queue is flushed.
  • max_diffs: When the number of stored diffs exceeds max_diffs, old diffs will be deleted.
  • path: The log path (defaults to default_path).
  • name: The name of the Ontology.
  • current: The path to the current state of the Ontology.
  • uwrite_queue: The queue in which undo actions are stored before being written to disk.
  • rwrite_queue: The queue in which redo actions are stored before being written to disk.

Methods:

  • diff: Creates a diff between 2 Files
  • read: Instantiates an Action Log with the data in the stored log at path.
  • flush_write_queues: Appends all entries in the write queue to the log file.
  • clear: Clears a queue in memory and on disk.
  • pop: Removes the last entry from a queue.
  • undo: Appends an entry to the redo write queue.
  • redo: Appends an entry to the undo write queue.
clear(queue)[source]

Clears queue both in memory and on disk.

default_path = '/home/docs/.pysumo/actionlog'
diff(current, new)[source]

Returns a diff between current and new.

flush_write_queues(_=None, __=None)[source]

Flush self.rwrite_queue and self.uwrite_queue to disk.

max_diffs = 100
max_size = 10
pop(queue)[source]

Removes the last entry in queue.

read()[source]

Reads the log at self.path into log.

redo(current, entry, clean=False)[source]

Append entry to self.uwrite_queue. If clean is True, pop an object from the redo queue.

timeout = 10
undo(current, entry)[source]

Append entry to self.rwrite_queue.

pysumo.logger.infolog module

!include ./UML/pysumo/logger/InfoLog.iuml


The pySUMO informational log handler. Acts as an initializer for the python logging framework and defines several convenience functions for working with it.

This module contains:

  • InfoLog: The informational log handler.
class pysumo.logger.infolog.InfoLog(loglevel='WARNING', filename='/home/docs/.pysumo/log', socket_path='/home/docs/.pysumo/status')[source]

The informational log handler for pySUMO. Initializes the python logging framework and contains several convenience functions. Instantiated only from the entry point.

Variables:

  • default_log_path: The default path where the infolog will be stored.
  • default_socket_path: The default socket to which >=INFO logs will be sent.
  • filename: The location at which the infolog will be stored.
  • root_logger: The root logging object of which all other loggers are children.
  • f_handler: Sends messages to a file and rotates it when it becomes too large.
  • s_handler: Sends messages to a Unix socket.

Methods:

  • set_loglevel: Sets the loglevel above which to log messages.
default_log_path = '/home/docs/.pysumo/log'
default_socket_path = '/home/docs/.pysumo/status'
set_loglevel(loglevel)[source]

Sets the loglevel above which to log messages.