Hide menu
Loading...
Searching...
No Matches
Logging Support

Overview

Manufacturing toolkit provides built-in logging functionality that can be used to trace execution, analyze behavior, and debug issues. Logging is handled through a global singleton instance: Utilities_Logger.Instance() .

The logger filters messages based on severity levels (Utilities_LoggerLevel ) and dispatches accepted messages to registered handlers.

Message delivery is synchronous, meaning execution continues only after all handlers have processed the message.

Message severity level

Message level is defined by an enumeration Utilities_LoggerLevel . The following levels are supported (given in the order of decreasing severity):

  • Fatal
  • Error
  • Warning
  • Info
  • Debug
  • Trace

Utilities_Logger.SetLevel() sets a threshold level for the messages which should be accepted by the logger. The messages sent with the same or greater level are accepted, the ones with a lower level are ignored.

The Debug and Trace levels are reserved for internal purposes and should not be used by the MTK users.

Quick Start

aLogger = mtk.Logger_Instance()
aLogger.SetLevel(LoggerLevel_Info)
aHandler = mtk.LoggerFileHandler("c:/temp/1.log")
aLogger.Register(aHandler, mtk.LoggerLevel_Info, mtk.LoggerLevel_Fatal)
Definition CadExMTK.py:1

Environment Variables

Variable Effect
MTK_LOG_FILE Enables logging to the specified file (absolute path required).

Handlers

Handlers are responsible for processing log messages. They implement the Utilities_LoggerHandler interface. The MTK provides the following built-in handlers:

Handlers are executed in the order they are registered. They must be unregistered before destruction.