All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.mostlyoriginal.plugin.LibgdxLoggingPlugin Maven / Gradle / Ivy

Go to download

LibGDX logging implementation. Register plugin with world, add uninitialized 'Log' field to your systems, Depenendecy Injection will do the rest.

There is a newer version: 2.5.0
Show newest version
package net.mostlyoriginal.plugin;

import com.badlogic.gdx.Gdx;
import net.mostlyoriginal.api.Log;
import net.mostlyoriginal.api.LoggingPlugin;

import java.util.logging.Level;

import static com.badlogic.gdx.Application.LOG_DEBUG;
import static com.badlogic.gdx.Application.LOG_ERROR;
import static com.badlogic.gdx.Application.LOG_INFO;

/**
 * Provides logging via LibGDX.
 * 

* Instructions: * 1. Add {@see net.mostlyoriginal.api.Log} to your systems for logging. * * @author Daan van Yperen * @since 2.3.0 */ public class LibgdxLoggingPlugin extends LoggingPlugin { @Override protected Object createLogger(Object target) { return new LibgdxLogImpl(target.getClass().getSimpleName()); } private static class LibgdxLogImpl implements Log { private final String tag; public LibgdxLogImpl(String tag) { this.tag = tag; } @Override public void info(String message) { Gdx.app.log(tag, message); } @Override public void info(String message, Object... args) { info(String.format(message, args)); } @Override public void error(String message) { Gdx.app.log(tag, message); } @Override public void error(String message, Object... args) { error(String.format(message, args)); } @Override public void debug(String message) { Gdx.app.debug(tag, message); } @Override public void debug(String message, Object... args) { debug(String.format(message, args)); } @Override public boolean isInfoEnabled() { return Gdx.app.getLogLevel() <= LOG_INFO; } @Override public boolean isErrorEnabled() { return Gdx.app.getLogLevel() <= LOG_ERROR; } @Override public boolean isDebugEnabled() { return Gdx.app.getLogLevel() <= LOG_DEBUG; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy