SG LOG

From FlightGear wiki
Revision as of 21:16, 24 August 2013 by Hooray (talk | contribs) (the talk page contained lots of useful info)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

SG_LOG is just a wrapper macro for the SimGear "logstream" class (all output being by default written to the console!). If you are interested in simply logging certain properties to a file at runtime, you may want to use another mechanism - which is more flexible and doesn't require recompilation (see below for more details).

So, the SG_LOG macro just simplifies usage, and is purely meant to be used by programmers/developers, who regularly recompile the source code. If you just want to log some runtime data to a file, there are several other more flexible ways to do this (possible via networking/scripting or XML).

Basically, the macro allows you to easily associate your debug messages with a "channel" and a "priority".

Which means that you can further specify each log message with a channel (think like a "parent" subsystem, to which the message belongs) and also a priority to indicate if it's a critical/non-critical message.

This mechanism allows users to explicitly enable/subscribe to certain log messages, only - while ignoring others. This can be helpful in order to troubleshoot certain problems.

Logging settings can be modified using the --log-level command line option, detailed help about most available command line options can be obtained from the fgfs executable by calling it with the following arguments: "--help --verbose".

All necessary details can be obtained from the source code (SG & FG) and its documentation/comments:

So, you just pass a channel and a logging priority/class to the macro, available log channels and priorities can be found here:

For logging only certain data/properties to a file, you may want to use another logging facility:


You can also add your own, custom, log level to SimGear, see $SG_SRC/debug/debug_types.h: http://docs.freeflightsim.org/simgear/debug__types_8h.html