Jump to content

Logging library


Recommended Posts

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.

Link to comment
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

Link to comment
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.

Link to comment
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.

Link to comment
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.

 

Link to comment
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, ...).

 

Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

  • 2 weeks later...
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...