Better error reporting and logging

DaveS

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Feb 4, 2008
Messages
9,434
Reaction score
688
Points
203
As I long time (nearly 20 years) user of Orbiter, something I have always wanted to see in Orbiter is much improved error reporting and logging. For the better part of a day now I have tried getting the ISS 2016 add-on to work with no luck. It seems to load everything just fine just to end with a CTD with no messages in the log.

This is something that needs to be improved greatly.
 

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,861
Reaction score
2,125
Points
203
Location
between the planets
Logging is mostly the job of the add-on, though. If the module developer doesn't log, there's not much the core can do about it. True, it could provide some better logging interface than just the one function, but there's also 3rd party solutions for that (well, at least one...).
 

GLS

Well-known member
Orbiter Contributor
Addon Developer
Joined
Mar 22, 2008
Messages
5,914
Reaction score
2,907
Points
188
Website
github.com
Logging is mostly the job of the add-on, though. If the module developer doesn't log, there's not much the core can do about it. True, it could provide some better logging interface than just the one function, but there's also 3rd party solutions for that (well, at least one...).
Well, there are 2*: the original oapiWriteLogV() and the multi-argument oapiWriteLogV(), which allows variables to be passed directly instead of having to write things to a buffer. The problem is people not using them...


*) and also oapiDebugString()
 

Urwumpe

Not funny anymore
Addon Developer
Donator
Joined
Feb 6, 2008
Messages
37,604
Reaction score
2,324
Points
203
Location
Wolfsburg
Preferred Pronouns
Sire
I think the worst problem for logging with Orbiter is the lack of a standard log format. That is mostly a human problem, not a technical one.
 

n72.75

Move slow and try not to break too much.
Orbiter Contributor
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 21, 2008
Messages
2,693
Reaction score
1,352
Points
128
Location
Saco, ME
Website
mwhume.space
Preferred Pronouns
he/him
Yeah, I tend to believe that the burden of logging is on the addon devs. Problems like "the user forgot to install a dependency" are easy and reported by Orbiter. Things like: "the addon dev created a rare case with access violations(or uninitalized variables, or something like that)", aren't really going to be caught by a log.

On the other hand, a debug build of Orbiter is going to be extremely useful in finding the exact calls that result in some weird/rare crashes.
 

n72.75

Move slow and try not to break too much.
Orbiter Contributor
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 21, 2008
Messages
2,693
Reaction score
1,352
Points
128
Location
Saco, ME
Website
mwhume.space
Preferred Pronouns
he/him
I just remembered we had a thread about this :)

I thought I would add this here as a reference. Martin added the function "oapiWriteLogError" to the post-2016 Orbiter code. NASSP takes advantage of this error logging function in exactly one place at the moment.


For reference our other log functions are:

C++:
    /**
    * \brief Writes a line to the Orbiter log file (orbiter.log) in the main orbiter directory.
    * \param line line to be written (zero-terminated)
    * \note This function is intended for diagnostic initialisation and error messages by
    *  plugin modules. The messages should make it easier to track problems.
    * \note Avoid unnecessary output. In particular, don't write to the log file continously
    *  from within the simulation loop.
    * \sa oapiWriteLogV
    */
OAPIFUNC void oapiWriteLog (char *line);

    /**
    * \brief Writes a formatted string with variable number of arguments to orbiter.log.
    * \param format Format string. Can contain any C-style parameter flags.
    * \param ... List of output parameters. Must match the parameter flags in the format string.
    * \note A newline character is appended to the end of the format string.
    * \sa oapiWriteLog
    */
OAPIFUNC void oapiWriteLogV (const char *format, ...);

    /**
    * \brief Writes a formatted error message with variable number of arguments to orbiter.log.
    * \param format Format string. Can contain any C-style parameter flags.
    * \param ... List of output parameters. Must match the parameter flags in the format string.
    * \sa oapiWriteLog, oapiWriteLogV
    */
#define oapiWriteLogError(format, ...) __writeLogError(__FUNCTION__,__FILE__,__LINE__, format, __VA_ARGS__)
OAPIFUNC void __writeLogError(const char *func, const char *file, int line, const char *format, ...);
 
Top