Skip to content

Logging

Hangman edited this page Sep 6, 2022 · 2 revisions

TuningFork is able to log various errors and events. By default, it logs through Gdx.

Set a logger

TuningForkLogger logger = new YourLogger();
AudioConfig config = new AudioConfig();
config.setLogger(logger);
audio = Audio.init(config);

Available built-in loggers

  • GdxLogger
    This is the default one that logs through libGDX.
  • ConsoleLogger
    This one uses System.out and let's you set a LogLevel.
AudioConfig config = new AudioConfig();
config.setLogger(new ConsoleLogger(LogLevel.INFO_WARN_ERROR));
audio = Audio.init(config);

Custom logger

If you want to use a custom logger, you can implement the TuningForkLogger interface. It looks like this:

public interface TuningForkLogger {
    void error(Class<?> clazz, String message);
    void warn(Class<?> clazz, String message);
    void info(Class<?> clazz, String message);
    void debug(Class<?> clazz, String message);
    void trace(Class<?> clazz, String message);
}

This way, it's also possible to build a bridge to other logging frameworks like log4j.

Disable logging

AudioConfig config = new AudioConfig();
config.setLogger(null);
audio = Audio.init(config);