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.
Initialize the MessageHandler.
# File lib/taskjuggler/MessageHandler.rb, line 122 def initialize reset end
Clear the error log.
# File lib/taskjuggler/MessageHandler.rb, line 152 def clear # A counter for messages of type error. @errors = 0 # A list of all generated messages. @messages = [] end
Generate an critical message.
# File lib/taskjuggler/MessageHandler.rb, line 183 def critical(id, message, sourceFileInfo = nil, line = nil, data = nil, scenario = nil) addMessage(:critical, id, message, sourceFileInfo, line, data, scenario) end
Generate a debug message.
# File lib/taskjuggler/MessageHandler.rb, line 201 def debug(id, message, sourceFileInfo = nil, line = nil, data = nil, scenario = nil) addMessage(:debug, id, message, sourceFileInfo, line, data, scenario) end
Generate an error message.
# File lib/taskjuggler/MessageHandler.rb, line 177 def error(id, message, sourceFileInfo = nil, line = nil, data = nil, scenario = nil) addMessage(:error, id, message, sourceFileInfo, line, data, scenario) end
Generate a fatal message that will abort the application.
# File lib/taskjuggler/MessageHandler.rb, line 171 def fatal(id, message, sourceFileInfo = nil, line = nil, data = nil, scenario = nil) addMessage(:fatal, id, message, sourceFileInfo, line, data, scenario) end
Generate an info message.
# File lib/taskjuggler/MessageHandler.rb, line 195 def info(id, message, sourceFileInfo = nil, line = nil, data = nil, scenario = nil) addMessage(:info, id, message, sourceFileInfo, line, data, scenario) end
Set the log output level.
# File lib/taskjuggler/MessageHandler.rb, line 166 def logLevel=(level) @logLevel = checkLevel(level) end
Set the console output level.
# File lib/taskjuggler/MessageHandler.rb, line 161 def outputLevel=(level) @outputLevel = checkLevel(level) end
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 128 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 # 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. @baselineSFI = nil # If this is set the true, we only throw a TjRuntimeError instead of # using exit(). @trapSetup = false clear end
Convert all messages into a single String.
# File lib/taskjuggler/MessageHandler.rb, line 207 def to_s text = '' @messages.each { |msg| text += msg.to_s } text end
Generate a warning.
# File lib/taskjuggler/MessageHandler.rb, line 189 def warning(id, message, sourceFileInfo = nil, line = nil, data = nil, scenario = nil) addMessage(:warning, id, message, sourceFileInfo, line, data, scenario) end