Logging

Usage

use Logging;

or

import Logging;
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

enum constant DEBUG
enum constant INFO
enum constant WARN
enum constant ERROR
enum constant CRITICAL
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.

enum constant CONSOLE
enum constant FILE
class OutputHandler
  • The OutputHandler class defines the interface for all derived

  • classes that write log messages to various channels.

proc write(message: string) throws
class ConsoleOutputHandler : OutputHandler
  • The ConsoleOutputHandler writes log messages to the Arkouda console.

override proc write(message: string) throws
class FileOutputHandler : OutputHandler
  • The FileOutputHandler writes log messages to the configured filePath.

var filePath : string
proc init(filePath: string)
override proc write(message: string) throws
proc writeToFile(filePath: string, line: string) throws
  • Writes to file, creating file if it does not exist

proc getOutputHandler(channel: LogChannel) : owned OutputHandler
  • 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.

var level : LogLevel = LogLevel.INFO
var printDate : bool = true
var outputHandler : owned OutputHandler = getOutputHandler(LogChannel.CONSOLE)
proc init()
proc init(level: LogLevel)
proc init(level: LogLevel, channel: LogChannel)
proc emit(msg: string ...)
proc report(moduleName: string, routineName: string, lineNumber: int, level: LogLevel, msg: string ...)
proc debug(moduleName, routineName, lineNumber, msg ...)
proc info(moduleName, routineName, lineNumber, msg ...)
proc warn(moduleName, routineName, lineNumber, msg ...)
proc error(moduleName, routineName, lineNumber, msg ...)
proc critical(moduleName, routineName, lineNumber, msg ...)
proc generateLogMessage(moduleName: string, routineName: string, lineNumber: int, level: LogLevel, msg: string ...)
proc generateDateTimeString(tail = "")