.. default-domain:: chpl .. module:: Logging Logging ======= **Usage** .. code-block:: chapel use Logging; or .. code-block:: chapel import Logging; .. enum:: enum LogLevel { DEBUG, INFO, WARN, ERROR, CRITICAL } * The LogLevel enum is used to provide a strongly-typed means of * configuring the logging level of a Logger object .. enumconstant:: enum constant DEBUG .. enumconstant:: enum constant INFO .. enumconstant:: enum constant WARN .. enumconstant:: enum constant ERROR .. enumconstant:: enum constant CRITICAL .. enum:: enum LogChannel { CONSOLE, FILE } * The LogChannel enum is used to provide a strongly-typed means of * configuring the channel such as stdout or file where log messages * are written. .. enumconstant:: enum constant CONSOLE .. enumconstant:: enum constant FILE .. class:: OutputHandler * The OutputHandler class defines the interface for all derived * classes that write log messages to various channels. .. method:: proc write(message: string) throws .. class:: ConsoleOutputHandler : OutputHandler * The ConsoleOutputHandler writes log messages to the Arkouda console. .. method:: override proc write(message: string) throws .. class:: FileOutputHandler : OutputHandler * The FileOutputHandler writes log messages to the configured filePath. .. attribute:: var filePath: string .. method:: proc init(filePath: string) .. method:: override proc write(message: string) throws .. method:: proc writeToFile(filePath: string, line: string) throws * Writes to file, creating file if it does not exist .. function:: proc getOutputHandler(channel: LogChannel): owned OutputHandler throws * getOutputHandler is a factory method for OutputHandler implementations. .. class:: Logger * The Logger class provides structured log messages at various levels * of logging sensitivity analogous to other languages such as Python. .. attribute:: var level: LogLevel = LogLevel.INFO .. attribute:: var warnLevels = new set(LogLevel, [LogLevel.WARN, LogLevel.INFO, LogLevel.DEBUG]) .. attribute:: var criticalLevels = new set(LogLevel, [LogLevel.CRITICAL, LogLevel.WARN, LogLevel.INFO, LogLevel.DEBUG]) .. attribute:: var errorLevels = new set(LogLevel, [LogLevel.ERROR, LogLevel.CRITICAL, LogLevel.WARN, LogLevel.INFO, LogLevel.DEBUG]) .. attribute:: var infoLevels = new set(LogLevel, [LogLevel.INFO, LogLevel.DEBUG]) .. attribute:: var printDate: bool = true .. attribute:: var outputHandler: owned OutputHandler = try! getOutputHandler(LogChannel.CONSOLE) .. method:: proc init() .. method:: proc init(level: LogLevel) .. method:: proc init(level: LogLevel, channel: LogChannel) .. method:: proc debug(moduleName, routineName, lineNumber, msg: string) throws .. method:: proc info(moduleName, routineName, lineNumber, msg: string) throws .. method:: proc warn(moduleName, routineName, lineNumber, msg: string) throws .. method:: proc critical(moduleName, routineName, lineNumber, msg: string) throws .. method:: proc error(moduleName, routineName, lineNumber, msg: string) throws .. method:: proc generateErrorMsg(moduleName: string, routineName, lineNumber, error) throws .. method:: proc generateLogMessage(moduleName: string, routineName, lineNumber, msg, level: string) throws .. method:: proc generateDateTimeString() throws