Talk:SG LOG

From FlightGear wiki
Jump to navigation Jump to search

Thanks to the person who filled this in--it helps. I was trying to figure out how some of the code worked, and which files were read in, which lead me to see calls to SG_LOG in the code. But I didn't figure out how to activate the logging of those messages.

you can enable these log messages by handing the parameter --log-level= one of the options supported (debug, bulk, alert ...)

I understood the idea behind it (logging class and level) but not the way to just activate it (for example, I want to be able to turn on logging of messages that are of class SG_GENERAL, and priority SG_INFO.

Frankly, I was also surprised that this very functionality doesn't yet seem to be exposed to the CLI (and actually had to edit my initial response therefore), i.e. there doesn't appear to be an option to also configure a log channel to be used. At least I couldn't really find it when I was looking for it.

I understand more of it now--so the log is not logging to a file but to the console (wish I knew how to redirect that to a file so I can search it later).

On many systems you can redirect console output to a file by using the '>' operator, depending on whether the input you are interested in is written to STDOUT or STDERR (or both) you may also have to slightly extend this, you may want to check out this for details, possibly also useful.

I see that to turn it on, I need to run fgfs --log-level=info (for example). Not sure how to select SG_GENERAL as the log class yet.

As I said, it only just occurred to me that there doesn't yet appear to be a command line switch to also specify the log channel. But this should be fairly straightforward to add, in addition the logstream class is already stream-based so it should be easy to make it directly write to a file instead - rather than having to redirect the output manually.

I plan to update this page with my complete understanding when I've figured out what I am trying to figure out.

As previously mentioned, these things are usually better discussed via official support means-this is just a community-driven wiki and not necessarily to be considered "official", nor an ideal place for discussions. While much of the info to be found here is meant to be accurate, none of it is guaranteed to be "official" or "correct" at all, most of it simply comes from fellow FlightGear users who may not necessarily be right about everything (or even anything) they're writing (including me).

I really opened this page b/c I think it will help others and it needs to be documented. I appreciate the info very much!

Assuming that you are not merely interested in the FlightGear logging system, you may also find it easier to simply directly ask those questions that you hope to get answered by inspecting FlightGear logs, you could also start a new wiki page for this purpose - maybe such a list of questions could eventually turn into an FAQ for new developers coming to FlightGear, at least so far this wiki doesn't yet really have such a "core developer's" section, so this might be a good start to get it going. After all, most of this started at some point pretty basic, too.

PS: I also added some more links to logging-related info below