Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8858 for code/trunk/data/lua


Ignore:
Timestamp:
Aug 23, 2011, 12:45:53 AM (13 years ago)
Author:
landauf
Message:

merged output branch back to trunk.

Changes:

  • you have to include util/Output.h instead of util/Debug.h
  • COUT(x) is now called orxout(level)
  • output levels are now defined by an enum instead of numbers. see util/Output.h for the definition
  • it's possible to use output contexts with orxout(level, context). see util/Output.h for some common contexts. you can define more contexts
  • you must use 'endl' at the end of an output message, '\n' does not flush the message

Output levels:

  • instead of COUT(0) use orxout()
  • instead of COUT(1) use orxout(user_error) or orxout(internal_error)
  • instead of COUT(2) use orxout(user_warning) or orxout(internal_warning)
  • instead of COUT(3) use orxout(user_status/user_info) or orxout(internal_status/internal_info)
  • instead of COUT(4) use orxout(verbose)
  • instead of COUT(5) use orxout(verbose_more)
  • instead of COUT(6) use orxout(verbose_ultra)

Guidelines:

  • user_* levels are for the user, visible in the console and the log-file
  • internal_* levels are for developers, visible in the log-file
  • verbose_* levels are for debugging, only visible if the context of the output is activated

Usage in C++:

  • orxout() << "message" << endl;
  • orxout(level) << "message" << endl;
  • orxout(level, context) << "message" << endl;

Usage in Lua:

  • orxout("message")
  • orxout(orxonox.level.levelname, "message")
  • orxout(orxonox.level.levelname, "context", "message")

Usage in Tcl (and in the in-game-console):

  • orxout levelname message
  • orxout_context levelname context message
  • shortcuts: log message, error message, warning message, status message, info message, debug message
Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/data/lua/LuaStateInit.lua

    r6746 r8858  
    77end
    88
    9 -- Create function to log text like COUT, but always prints a line!
    10 logMessage = function(level, message)
    11   luaState:luaLog(level, message)
     9-- Prints output to the console and the logfile
     10--
     11-- Accepts the following arguments:
     12--   orxout("message")
     13--   orxout(orxonox.level.levelname, "message")
     14--   orxout(orxonox.level.levelname, "context", "message)
     15orxout = function(arg1, arg2, arg3)
     16  if arg1 and arg2 and arg3 then
     17    luaState:luaOutput(arg1, arg2, arg3)
     18  elseif arg1 and arg2 then
     19    luaState:luaOutput(arg1, arg2)
     20  else
     21    luaState:luaOutput(arg1)
     22  end
    1223end
    13 cout = logMessage
    1424
    1525-- Redirect dofile in order to load with the resource manager
     
    4252require = function(moduleName)
    4353  if not luaState:fileExists(moduleName .. ".lua") then
    44     logMessage(2, "Warning: Lua function require() could not find file '" .. moduleName .. ".lua' ")
     54    orxout(orxonox.level.internal_warning, "Warning: Lua function require() could not find file '" .. moduleName .. ".lua' ")
    4555    return nil
    4656  end
     
    8595  -- Fallback pause function
    8696  pause = function()
    87     logMessage(2, [["Warning: debug() called in Lua, but Debugger is not active.
     97    orxout(orxonox.level.internal_warning, [["Warning: debug() called in Lua, but Debugger is not active.
    8898Do you have the IOConsole disabled and are you using Lua version 5.1?"]])
    8999  end
     
    98108    end
    99109    -- Display the error message
    100     logMessage(1, "Lua runtime error: "..err)
     110    orxout(orxonox.level.internal_error, "Lua runtime error: "..err)
    101111  end
    102112
     
    106116  else
    107117    -- Fallback: print stack trace
    108     logMessage(3, debug.traceback(""))
     118    orxout(orxonox.level.internal_error, debug.traceback(""))
    109119  end
    110120  return err -- Hello Lua debugger user! Please type 'set 2' to get to the
Note: See TracChangeset for help on using the changeset viewer.