class TaskJuggler::MessageHandlerInstance

The MessageHandler can display and store application messages. Depending on the type of the message, a TjExeption can be raised (:error), or the program can be immedidately aborted (:fatal). Other types will just continue the program flow.

Constants

LogLevels

Attributes

abortOnWarning[RW]
appName[RW]
errors[R]
logFile[RW]
messages[R]

Public Class Methods

new() click to toggle source

Initialize the MessageHandler.

# File lib/taskjuggler/MessageHandler.rb, line 123
def initialize
  reset
end

Public Instance Methods

baselineSFI=(line) click to toggle source
# File lib/taskjuggler/MessageHandler.rb, line 156
def baselineSFI=(line)
  @baselineSFI[Thread.current.object_id] = line
end
clear() click to toggle source

Clear the error log.

# File lib/taskjuggler/MessageHandler.rb, line 165
def clear
  # A counter for messages of type error.
  @errors = 0
  # A list of all generated messages.
  @messages = []
end
critical(id, message, sourceFileInfo = nil, line = nil, data = nil, scenario = nil) click to toggle source

Generate an critical message.

# File lib/taskjuggler/MessageHandler.rb, line 199
def critical(id, message, sourceFileInfo = nil, line = nil, data = nil,
             scenario = nil)
  addMessage(:critical, id, message, sourceFileInfo, line, data, scenario)
end
debug(id, message, sourceFileInfo = nil, line = nil, data = nil, scenario = nil) click to toggle source

Generate a debug message.

# File lib/taskjuggler/MessageHandler.rb, line 217
def debug(id, message, sourceFileInfo = nil, line = nil, data = nil,
          scenario = nil)
  addMessage(:debug, id, message, sourceFileInfo, line, data, scenario)
end
error(id, message, sourceFileInfo = nil, line = nil, data = nil, scenario = nil) click to toggle source

Generate an error message.

# File lib/taskjuggler/MessageHandler.rb, line 193
def error(id, message, sourceFileInfo = nil, line = nil, data = nil,
          scenario = nil)
  addMessage(:error, id, message, sourceFileInfo, line, data, scenario)
end
fatal(id, message, sourceFileInfo = nil, line = nil, data = nil, scenario = nil) click to toggle source

Generate a fatal message that will abort the application.

# File lib/taskjuggler/MessageHandler.rb, line 187
def fatal(id, message, sourceFileInfo = nil, line = nil, data = nil,
          scenario = nil)
  addMessage(:fatal, id, message, sourceFileInfo, line, data, scenario)
end
hideScenario=(yesNo) click to toggle source
# File lib/taskjuggler/MessageHandler.rb, line 182
def hideScenario=(yesNo)
  @hideScenario = yesNo
end
info(id, message, sourceFileInfo = nil, line = nil, data = nil, scenario = nil) click to toggle source

Generate an info message.

# File lib/taskjuggler/MessageHandler.rb, line 211
def info(id, message, sourceFileInfo = nil, line = nil, data = nil,
         scenario = nil)
  addMessage(:info, id, message, sourceFileInfo, line, data, scenario)
end
logLevel=(level) click to toggle source

Set the log output level.

# File lib/taskjuggler/MessageHandler.rb, line 178
def logLevel=(level)
  @logLevel = checkLevel(level)
end
outputLevel=(level) click to toggle source

Set the console output level.

# File lib/taskjuggler/MessageHandler.rb, line 173
def outputLevel=(level)
  @outputLevel = checkLevel(level)
end
reset() click to toggle source

Reset the MessageHandler to the initial state. All messages will be purged and the error counter set to 0.

# File lib/taskjuggler/MessageHandler.rb, line 129
def reset
  # This setting controls what type of messages will be written to the
  # console.
  @outputLevel = 4
  # This setting controls what type of messages will be written to the log
  # file.
  @logLevel = 3
  # The full file name of the log file.
  @logFile = nil
  # Toggle if scenario ids are included in the messages or not.
  @hideScenario = true
  # The name of the current application
  @appName = 'unknown'
  # Set to true if program should be exited on warnings.
  @abortOnWarning = false
  # A SourceFileInfo object that will be used to baseline the provided
  # source file infos of the messages. We use a Hash to keep per Thread
  # values.
  @baselineSFI = {}
  # Each tread can request to only throw a TjRuntimeError instead of
  # using exit(). This hash keeps a flag for each thread using the
  # object_id of the Thread object as key.
  @trapSetup = {}

  clear
end
to_s() click to toggle source

Convert all messages into a single String.

# File lib/taskjuggler/MessageHandler.rb, line 223
def to_s
  text = ''
  @messages.each { |msg| text += msg.to_s }
  text
end
trapSetup=(enable) click to toggle source
# File lib/taskjuggler/MessageHandler.rb, line 160
def trapSetup=(enable)
  @trapSetup[Thread.current.object_id] = enable
end
warning(id, message, sourceFileInfo = nil, line = nil, data = nil, scenario = nil) click to toggle source

Generate a warning.

# File lib/taskjuggler/MessageHandler.rb, line 205
def warning(id, message, sourceFileInfo = nil, line = nil, data = nil,
            scenario = nil)
  addMessage(:warning, id, message, sourceFileInfo, line, data, scenario)
end