Misc Olog - a simple logging library for orbiter

RisingFury

OBSP developer
Addon Developer
Joined
Aug 15, 2008
Messages
6,427
Reaction score
492
Points
173
Location
Among bits and Bytes...
- When an unknown log level is given from a file, instead of throwing an error, default to some log level and throw a warning of some kind.

- In assertThat, are you sure you want to throw stuff? This is a logger. It's used for when someone's code is already crashy and buggy. Thrown exceptions that aren't caught cause a crash, so you're introducing another point where the code can crash. Is this a good design choice for a logger?
 

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,883
Reaction score
2,136
Points
203
Location
between the planets
- When an unknown log level is given from a file, instead of throwing an error, default to some log level and throw a warning of some kind.

It does default to the log level you previously set. As for changing the error to a warning, I debated that, and went with the error. I can easily change that, of course, the distinction between an error and a warning is at times a bit semantic.

In assertThat, are you sure you want to throw stuff?

Yes, actually, about that one I'm dead certain :).

Thrown exceptions that aren't caught cause a crash, so you're introducing another point where the code can crash.

Which is of course the entire point of an assert. It's the "rather crash and tell me something is wrong than maybe succeed but behave weirdly and let me desperately search for what is wrong" paradigm.
The difference to a normal assert is that you get log output, which is indispensible when people are testing your code that are not building and running it in visual studio themselves. Because in that case, you just get cryptic windows messages from standard asserts or exceptions, which sucks.

That said, maybe there is also a small misunderstanding here. assertThat is simply a bonus which you might or might not want to use (I happen to desperately need it, so desperately that it was the first thing I wrote of the entire library...). Just logging an error will not throw anything, as you'd expect it just logs.
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,403
Reaction score
581
Points
153
Location
Vienna
Having used log4net heavily in OMP, I initially thought this might be reinventing the wheel. Especially since log4net has many features I've used such as log rotating, custom appenders and remote sink logging over network. Now I know that Orbiter dev is mainly in C++, but there are comparable frameworks for that language, too (e.g. log4cxx).

However, given that it is lean, tightly cut for Orbiter usage, and even MIT licensed, I see it as a welcome contribution. :thumbup:

---------- Post added at 10:18 ---------- Previous post was at 10:14 ----------

That said, maybe there is also a small misunderstanding here. assertThat is simply a bonus which you might or might not want to use (I happen to desperately need it, so desperately that it was the first thing I wrote of the entire library...). Just logging an error will not throw anything, as you'd expect it just logs.

That plus the fact that you can always throw out the line throwing the exception in your project. After all, the code is small enough to be included in the addon's source, and modified to your needs.
 

Xyon

Puts the Fun in Dysfunctional
Administrator
Moderator
Orbiter Contributor
Addon Developer
Webmaster
GFX Staff
Beta Tester
Joined
Aug 9, 2009
Messages
6,927
Reaction score
795
Points
203
Location
10.0.0.1
Website
www.orbiter-radio.co.uk
Preferred Pronouns
she/her
This looks useful, and a FOSS licence is certainly welcome. I feel this is something I could make use of in upcoming projects.

Thanks for sharing!
 
Top