tomf

Logging library

11 posts in this topic

Has anyone ever thought of creating a proper logging library for KSP? In java I am used to things like logback which give you lots of control over how your logging is written and makes it easy to configure.

1 person likes this

Share this post


Link to post
Share on other sites

I'm deeply disappointed that this post was a question and not a release announcement. :wink:

Share this post


Link to post
Share on other sites

Do we really need a rolling file appender with daily and size trigger in KSP ? You have a Debug.Log,  Debug.LogWarning and Debug.LogError. Adding a static call that only uses one of those when some var is set is not exactly a thousands lines project

Share this post


Link to post
Share on other sites
Just now, sarbian said:

Do we really need a rolling file appender with daily and size trigger in KSP ? You have a Debug.Log,  Debug.LogWarning and Debug.LogError. Adding a static call that only uses one of those when some var is set is not exactly a thousands lines project

No, but the ability to turn have levels of logging and to turn on and off logging for different classes would be useful. I frequently have people reporting issues that I can't diagnose without adding a bunch of logging, but releasing that logging to all users is going to be a significant slowdown. It would be nice to be able to provide a simple config change that would turn on logging for just the affected person.

Share this post


Link to post
Share on other sites
Just now, tomf said:

No, but the ability to turn have levels of logging and to turn on and off logging for different classes would be useful. I frequently have people reporting issues that I can't diagnose without adding a bunch of logging, but releasing that logging to all users is going to be a significant slowdown. It would be nice to be able to provide a simple config change that would turn on logging for just the affected person.

Indeed, I did not though of that case. Worth having a look.

Share this post


Link to post
Share on other sites

Frankly I'd settle for an "alternate debug download" in Github releases. Then if someone's having an issue, they can install that version and send in logs.

Share this post


Link to post
Share on other sites

Personally I don't like the idea of installing an extra dependency mod just for logging.  I just add a debugLogging configuration setting and do extra logging when it's enabled... even in Update()/FixedUpdate() these checks aren't going to take enough extra time to matter.  (But you shouldn't log repeatedly in there anyhow... aggregate it and log once at the end instead.)

I also send everything through my own methods which tack on the mod prefix in square brackets.  Not only does this make the messages easier to find, but in the Alt+F12 display KSP will do colouring based on that.

 

Share this post


Link to post
Share on other sites

I have been pondering to create a Telemetry library, but that would be a different focus. I would like to have a library for logging numerical values that help to debug KSP math/simulations.

Kind of like writing to CSV files in every frame, but buffered and configurable (channels, frequency, ...).

 

Share this post


Link to post
Share on other sites
17 hours ago, paulprogart said:

Personally I don't like the idea of installing an extra dependency mod just for logging.  I just add a debugLogging configuration setting and do extra logging when it's enabled... even in Update()/FixedUpdate() these checks aren't going to take enough extra time to matter.  (But you shouldn't log repeatedly in there anyhow... aggregate it and log once at the end instead.)

I also send everything through my own methods which tack on the mod prefix in square brackets.  Not only does this make the messages easier to find, but in the Alt+F12 display KSP will do colouring based on that.

 

This could just be a source file you add to your project. 

But runtime conditional logging usually has the default of allocating the strings even when disabled... Building with a [Conditional("DEBUG")] attribute on your logging calls may indeed be a better idea.

1 person likes this

Share this post


Link to post
Share on other sites
19 hours ago, HebaruSan said:

Frankly I'd settle for an "alternate debug download" in Github releases. Then if someone's having an issue, they can install that version and send in logs.

I think that makes sense too.

Share this post


Link to post
Share on other sites

I use a (for me) standardized log library for many of my mods.  I got it from somewhere, and have made changes over time.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now