User Tools

Site Tools


dev:logging_and_debugging

This is an old revision of the document!


Logging and Debugging

Here are a few quick notes on getting logging output from the simulator.

  • The simulator has a logging system accessed via the static object LOG.
  • The logging system has a 'level' determining how much output is desired. The level can be set on the command line by the -l NUM switch, where NUM can range from 0 (for the least output) to 8 (for the most output).
  • The logging levels have names and numbers: NONE(0), ERROR(1), WARNING(2), MESSAGE(3), DEBUG(4), DEBUG1(5), DEBUG2(6), DEBUG3(7), and ALL(8).
  • The logging code provides direct methods for producing output at levels ERROR, WARNING, MESSAGE, and DEBUG. For example:
    LOG.Debug("Hi there");

    prints 'Hi there' to the console and the logging buffer (whose display is toggled by 'l' in the GUI) – if the logging level is 4 or larger.

  • LOG offers simple, internally-implemented 'printf-like' functionality. Its biggest current limitation is no floating point support (so, no '%f', '%e', or '%g' conversions). For example:
  virtual void Behavior(EventWindow<CC>& window) const
  {
    T self = window.GetCenterAtom();
    LOG.Message("At (%d,%d): type is %04x (%s)",
                window.GetCenterInTile().GetX(),
                window.GetCenterInTile().GetY(),
                self.GetType(),
                "so there");
 
  }

might print something like 20140928032150-3123: At (14,3): type is 00F0 (so there) if the logging level was 3 or higher.

  • Note the logger adds a newline at the end of each log message, so typically it's expected that each log message will be a single line.
dev/logging_and_debugging.1411896509.txt.gz · Last modified: 2014/09/28 09:28 by ackley