BugInit error

Is there some guidelines or a tutorial on how to set up a log file under BUG. It would make my life easier than trying to catch messages flashing up on the screen.

Check out the Troubleshooting page in my sig.
 
OK, I was not articulating my need clearly, my fault.

I am making a mod SubdueAnimals based on Roamty's work but expanding it a bit adding new units and new buildings. Initially it is for Rise of Mankind but it may be usable in other mods.

It uses "metadata" which the modder enters in the init code to say what animal is subdued as what subdued animal.

What I want to do is write some logging error messages from the python if there is problems with this metadata. That way I can drop invalid rules, not breaking the game but providing feedback about problems.

While I am building the mod (and others) I would like to put tracing messages in the log also.

So basically my questions are:-
- Does BUG provide a means of writing to logs?
- Does it allow me to specify a log?
- What is usually written to which log files?
- How do I write to a log file?
OR
- Is there a place which covers log file usage?

I have been slack and not built one for myself.;)
 
Yes, yes and YES!

Import BugUtil into your python file, then use this function:

BugUtil.debug(string) or BugUtil.warn(string), and you can enable logging via the bug manager to the PythonDebug file. The text that you complained about flashing on the screen, well it will be logged to the PythonDebug file. BUG is the best python debugging tool for Civ!
 
I really do need to add a page about logging to the tutorial!

BUG will write to only one log file (Logs/PythonDbg.log) and the screen in the event message area. Where it writes (one or the other or both) depend on the logging settings on the System tab of the BUG Options screen. Each device (file and screen) has a minimum logging severity level, and any messages at that level or "more severe" are logged to that device. The levels in increasing severity are debug, info, warn, error, and the functions in BugUtil have the same name.

They all take the same parameters: a string message followed by zero or more replacement variables that get placed into the string using Python's % operator.

Code:
BugUtil.debug("Checking plot at %d, %d for player %s", pPlot.getX(), pPlot.getY(), pPlayer.getName())
BugUtil.warn("Directory %s doesn't exist", dir)

The full message is only built if it will be logged to at least one device, so you needn't worry about having your debug logging of large objects slowing down the game when logging is turned off (or down to show only errors).
 
Top Bottom