extools.message

class extools.message.ExMessages(name, level=None, log_path=None, programs=[], box=True, disabled=False, key='', handler=None)[source]

Bases: object

A logger like object for writing messages for the user.

The ExtenderMessageWriter acts like a logger, allowing a developer to add messages that are only displayed to the user if the current level is greater than or equal to the message level being called.

Messages at debug and below, as well as those at error or above, support displaying the last exception traceback to make debugging easier.

Parameters:
  • name (str) – the name to log under.
  • level (int) – the level at and below which to display messages.
  • log_path (str) – the path of a log file to write to.
  • programs (list) – the list of programs for which to display messages. For example, if programs were [“OE1100”, ] then messages will only be displayed if the Order Entry program is currently running.
  • box (True (showMessageBox), False (message stack), None (suppress)) – indicates whether to show a message box, add a message to the Sage message stack, or suppress UI messages. Defaults to True.
  • disabled (bool) – disable all messages and logging. Defaults to False.
CRITICAL = 1
DEBUG = 20
ERROR = 5
INFO = 15
LEVELS = (0, 1, 5, 10, 15, 20, 25)

Supported log levels in decreasing order of severity.

PANIC = 0
RAW = 25
WARNING = 10
YES_NO_DIALOG = 4
YES_NO_DIALOG_NO = 7
YES_NO_DIALOG_YES = 6
crit(msg, exc_info=None)[source]

Display and log a critical message.

Parameters:
  • msg (str) – message to write.
  • exc_info (bool) – include last exception backtrace?
Return type:

None

debug(msg, exc_info=False)[source]

Display and log a debug message.

Parameters:
  • msg (str) – message to write.
  • exc_info (bool) – include last exception backtrace?
Return type:

None

debug_error_stack()[source]

Write the contents of the error stack to log as debug messages and clear the stack.

error(msg, exc_info=None)[source]

Display and log an error message.

Parameters:
  • msg (str) – message to write.
  • exc_info (bool) – include last exception backtrace?
Return type:

None

info(msg)[source]

Display and log an info message.

Parameters:msg (str) – message to write.
Return type:None
panic(msg, exc_info=None)[source]

Display and log a panic message.

Parameters:
  • msg (str) – message to write.
  • exc_info (bool) – include last exception backtrace?
Return type:

None

classmethod prompt(title, message)[source]

Display a Yes/No dialog prompt.

Parameters:
  • title (str) – The message box title.
  • message (str) – The prompt to display.
Returns:

True if User selects Yes, else No

Return type:

bool

raw(msg, exc_info=False)[source]

Display and log raw output.

Parameters:
  • msg (str) – message to write.
  • exc_info (bool) – include last exception backtrace?
Return type:

None

warn(msg)[source]

Display and log a warning message.

Parameters:msg (str) – message to write.
Return type:None
extools.message.logger_for_module(module_name, level=None, box=None, **kwargs)[source]