SG LOG: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
No edit summary
(Cleanup)
Line 1: Line 1:
{{merge|SG_LOG()}}
{{merge|SG_LOG()}}
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.
<code>SG_LOG</code> is a wrapper macro for the [[SimGear]] <code>logstream</code> class.  By default, the <code>logstream</code> class writes all output to the console.  <code>SG_LOG</code> simplifies debugging for core developers who regularly [[Building FlightGear|compile from source]]. It allows you to easily associate your debug messages with a "channel" and with a "priority". This mechanism allows users to explicitly enable to certain log messages, while ignoring others. This can be helpful in order to troubleshoot certain problems.
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".
Logging settings can be modified using the <code>--log-level=[level]</code> [[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: <code>--help --verbose</code>.


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.
If you are interested in simply logging certain properties to a file at runtime, you can use either FlightGear's built-in logging framework, or the [[generic protocol]].  See [[Logging properties]] and [[Generic protocol]] for more details.


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.
== External links ==
 
* {{repo link|site=gito|proj=fg/simgear|path=simgear/debug/logstream.cxx}}
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".
* {{repo link|site=gito|proj=fg/simgear|path=simgear/debug/logstream.hxx}}
 
* {{repo link|site=gito|proj=fg/simgear|path=simgear/debug/debug_types.h}}
All necessary details can be obtained from the source code (SG & FG) and its documentation/comments:
* http://www.simgear.org/doxygen/structlogstream__base.html
* http://simgear.org/doxygen/logstream_8hxx.html
* http://simgear.org/doxygen/logstream_8hxx-source.html
* http://www.simgear.org/doxygen/classlogstream.html
* http://www.simgear.org/doxygen/structloglevel.html
* http://www.simgear.org/doxygen/classlogbuf.html
 
So, you just pass a channel and a logging priority/class to the macro, available log channels and priorities can be found here:
* http://simgear.org/doxygen/debug__types_8h.html
* http://simgear.org/doxygen/debug__types_8h-source.html
* http://cvs.flightgear.org/simgear/doxygen/debug__types_8h-source.html
 
For logging only certain data/properties to a file, you may want to use another logging facility:
* http://cvs.flightgear.org/viewvc/source/src/Main/logger.cxx?revision=1.7&view=markup
 
 
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


[[Category:Core developer documentation]]
[[Category:Core developer documentation]]

Revision as of 11:38, 5 March 2015

Merge-arrows.gif
It has been suggested that this article or section be merged with SG_LOG().

SG_LOG is a wrapper macro for the SimGear logstream class. By default, the logstream class writes all output to the console. SG_LOG simplifies debugging for core developers who regularly compile from source. It allows you to easily associate your debug messages with a "channel" and with a "priority". This mechanism allows users to explicitly enable to certain log messages, while ignoring others. This can be helpful in order to troubleshoot certain problems.

Logging settings can be modified using the --log-level=[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.

If you are interested in simply logging certain properties to a file at runtime, you can use either FlightGear's built-in logging framework, or the generic protocol. See Logging properties and Generic protocol for more details.

External links