Giter Club home page Giter Club logo

Comments (6)

czyzby avatar czyzby commented on May 22, 2024 1

I really wanted to go for simplicity and as little overhead as possible. Customized logging functions could easily introduce concurrency bugs when done wrong. Instead of refactoring current logging mechanism, I decided to make it possible to extend Logger with customized tags - an example of logger that includes current time was added to the README file.

Anyway, I'm guessing most people will be fine with the usual Logger and static logging methods (as they are already more flexible and efficient than the usual LibGDX logging), and others can easily modify the way their logs are displayed.

from ktx.

czyzby avatar czyzby commented on May 22, 2024

@kotcrab Anything else? We could add custom trace/warn levels that work on top of LibGDX debug and info/error, but I'm not sure if that's necessary (especially since we would likely have to introduce new logging level variables).

from ktx.

kotcrab avatar kotcrab commented on May 22, 2024

Well this is a wrapper over libGDX API, I don't think we should add custom levels. I would expect a way to customize output message, eg. prepend time or date, otherwise people will probably still create their own wrappers, and maybe add some control to disable log levels (e.g. only show error messages).

from ktx.

czyzby avatar czyzby commented on May 22, 2024

The thing is - since Logger methods are inlined, I'm not sure if an interface or complex logging logic would work in this case. We're going for minimal overhead, after all.

I might create another Logger implementation that adds dates before/after the logging tag, but I'm not sure if full control over log structure is easily achievable.

Log level disabling is handled by the LibGDX itself. You can globally turn on and off the levels that you do or do not need.

from ktx.

kotcrab avatar kotcrab commented on May 22, 2024

Message formatting can be simply achieved as changeable global method.

//logger file
var formatLogMessage: (String) -> String = { it }

//app class
fun myAppInit() {
  formatLogMessage = { getTimestamp() + it  }
}

The same could be done for default log level tags, although I'm not sure if that would be good practice or not.

from ktx.

czyzby avatar czyzby commented on May 22, 2024

Adds the overhead of calling another method (formatLogMessage), even if you don't want an alternate formatting. Doesn't really matter that much, as logs are usually more important for development time, but still.

Imho a complex, customizable logger (that still uses inlining) would be a more lightweight solution, although it could be a pain to refactor your application to switch from one to the other. I have to think about it.

from ktx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.