Class SdlLog
- java.lang.Object
-
- io.github.libsdl4j.api.log.SdlLog
-
public final class SdlLog extends Object
Definitions from file SDL_log.hSimple log messages with categories and priorities.
By default logs are quiet, but if you're debugging SDL you might want:
SDL_LogSetAllPriority(SDL_LOG_PRIORITY_WARN);
Here's where the messages go on different platforms: Windows: debug output stream Android: log output Others: standard error output (stderr)
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
routeSdlLoggingToSlf4j(com.sun.jna.Pointer userdata, int category, int priority, String message)
Log message handler that will route all SDL internal logging to Java's SLF4J.static void
SDL_Log(String fmt, Object... args)
Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO.static void
SDL_LogCritical(int category, String fmt, Object... args)
Log a message with SDL_LOG_PRIORITY_CRITICAL.static void
SDL_LogDebug(int category, String fmt, Object... args)
Log a message with SDL_LOG_PRIORITY_DEBUG.static void
SDL_LogError(int category, String fmt, Object... args)
Log a message with SDL_LOG_PRIORITY_ERROR.static void
SDL_LogGetOutputFunction(com.sun.jna.ptr.PointerByReference callback, com.sun.jna.ptr.PointerByReference userdata)
Get the current log output function.static int
SDL_LogGetPriority(int category)
Get the priority of a particular log category.static void
SDL_LogInfo(int category, String fmt, Object... args)
Log a message with SDL_LOG_PRIORITY_INFO.static void
SDL_LogMessage(int category, int priority, String fmt, Object... args)
Log a message with the specified category and priority.static void
SDL_LogResetPriorities()
Reset all priorities to default.static void
SDL_LogSetAllPriority(int priority)
Set the priority of all log categories.static void
SDL_LogSetOutputFunction(com.sun.jna.Pointer callback, com.sun.jna.Pointer userdata)
Replace the default log output function with one of your own.static void
SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, com.sun.jna.Pointer userdata)
Replace the default log output function with one of your own.static void
SDL_LogSetPriority(int category, int priority)
Set the priority of a particular log category.static void
SDL_LogVerbose(int category, String fmt, Object... args)
Log a message with SDL_LOG_PRIORITY_VERBOSE.static void
SDL_LogWarn(int category, String fmt, Object... args)
Log a message with SDL_LOG_PRIORITY_WARN.
-
-
-
Method Detail
-
SDL_LogSetAllPriority
public static void SDL_LogSetAllPriority(int priority)
Set the priority of all log categories.- Parameters:
priority
- the SDL_LogPriority to assign- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_LogSetPriority(int, int)
-
SDL_LogSetPriority
public static void SDL_LogSetPriority(int category, int priority)
Set the priority of a particular log category.- Parameters:
category
- the category to assign a priority topriority
- the SDL_LogPriority to assign- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_LogGetPriority(int)
,SDL_LogSetAllPriority(int)
-
SDL_LogGetPriority
public static int SDL_LogGetPriority(int category)
Get the priority of a particular log category.- Parameters:
category
- the category to query- Returns:
- the SDL_LogPriority for the requested category
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_LogSetPriority(int, int)
-
SDL_LogResetPriorities
public static void SDL_LogResetPriorities()
Reset all priorities to default.This is called by SDL_Quit().
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_LogSetAllPriority(int)
,SDL_LogSetPriority(int, int)
-
SDL_Log
public static void SDL_Log(String fmt, Object... args)
Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO.- Parameters:
fmt
- a printf() style message format stringargs
- additional parameters matching % tokens in thefmt
string, if any- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_LogCritical(int, String, Object...)
,SDL_LogDebug(int, String, Object...)
,SDL_LogError(int, String, Object...)
,SDL_LogInfo(int, String, Object...)
,SDL_LogMessage(int, int, String, Object...)
,SDL_LogVerbose(int, String, Object...)
,SDL_LogWarn(int, String, Object...)
-
SDL_LogVerbose
public static void SDL_LogVerbose(int category, String fmt, Object... args)
Log a message with SDL_LOG_PRIORITY_VERBOSE.- Parameters:
category
- the category of the messagefmt
- a printf() style message format stringargs
- additional parameters matching % tokens in the **fmt** string, if any- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_Log(String, Object...)
,SDL_LogCritical(int, String, Object...)
,SDL_LogDebug(int, String, Object...)
,SDL_LogError(int, String, Object...)
,SDL_LogInfo(int, String, Object...)
,SDL_LogMessage(int, int, String, Object...)
,SDL_LogWarn(int, String, Object...)
-
SDL_LogDebug
public static void SDL_LogDebug(int category, String fmt, Object... args)
Log a message with SDL_LOG_PRIORITY_DEBUG.- Parameters:
category
- the category of the messagefmt
- a printf() style message format stringargs
- additional parameters matching % tokens in the **fmt** string, if any- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_Log(String, Object...)
,SDL_LogCritical(int, String, Object...)
,SDL_LogDebug(int, String, Object...)
,SDL_LogError(int, String, Object...)
,SDL_LogInfo(int, String, Object...)
,SDL_LogMessage(int, int, String, Object...)
,SDL_LogWarn(int, String, Object...)
-
SDL_LogInfo
public static void SDL_LogInfo(int category, String fmt, Object... args)
Log a message with SDL_LOG_PRIORITY_INFO.- Parameters:
category
- the category of the messagefmt
- a printf() style message format stringargs
- additional parameters matching % tokens in the **fmt** string, if any- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_Log(String, Object...)
,SDL_LogCritical(int, String, Object...)
,SDL_LogDebug(int, String, Object...)
,SDL_LogError(int, String, Object...)
,SDL_LogInfo(int, String, Object...)
,SDL_LogMessage(int, int, String, Object...)
,SDL_LogWarn(int, String, Object...)
-
SDL_LogWarn
public static void SDL_LogWarn(int category, String fmt, Object... args)
Log a message with SDL_LOG_PRIORITY_WARN.- Parameters:
category
- the category of the messagefmt
- a printf() style message format stringargs
- additional parameters matching % tokens in the **fmt** string, if any- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_Log(String, Object...)
,SDL_LogCritical(int, String, Object...)
,SDL_LogDebug(int, String, Object...)
,SDL_LogError(int, String, Object...)
,SDL_LogInfo(int, String, Object...)
,SDL_LogMessage(int, int, String, Object...)
,SDL_LogWarn(int, String, Object...)
-
SDL_LogError
public static void SDL_LogError(int category, String fmt, Object... args)
Log a message with SDL_LOG_PRIORITY_ERROR.- Parameters:
category
- the category of the messagefmt
- a printf() style message format stringargs
- additional parameters matching % tokens in the **fmt** string, if any- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_Log(String, Object...)
,SDL_LogCritical(int, String, Object...)
,SDL_LogDebug(int, String, Object...)
,SDL_LogError(int, String, Object...)
,SDL_LogInfo(int, String, Object...)
,SDL_LogMessage(int, int, String, Object...)
,SDL_LogWarn(int, String, Object...)
-
SDL_LogCritical
public static void SDL_LogCritical(int category, String fmt, Object... args)
Log a message with SDL_LOG_PRIORITY_CRITICAL.- Parameters:
category
- the category of the messagefmt
- a printf() style message format stringargs
- additional parameters matching % tokens in the **fmt** string, if any- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_Log(String, Object...)
,SDL_LogCritical(int, String, Object...)
,SDL_LogDebug(int, String, Object...)
,SDL_LogError(int, String, Object...)
,SDL_LogInfo(int, String, Object...)
,SDL_LogMessage(int, int, String, Object...)
,SDL_LogWarn(int, String, Object...)
-
SDL_LogMessage
public static void SDL_LogMessage(int category, int priority, String fmt, Object... args)
Log a message with the specified category and priority.- Parameters:
category
- the category of the messagepriority
- the priority of the messagefmt
- a printf() style message format stringargs
- additional parameters matching % tokens in the **fmt** string, if any- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_Log(String, Object...)
,SDL_LogCritical(int, String, Object...)
,SDL_LogDebug(int, String, Object...)
,SDL_LogError(int, String, Object...)
,SDL_LogInfo(int, String, Object...)
,SDL_LogMessage(int, int, String, Object...)
,SDL_LogWarn(int, String, Object...)
-
SDL_LogGetOutputFunction
public static void SDL_LogGetOutputFunction(com.sun.jna.ptr.PointerByReference callback, com.sun.jna.ptr.PointerByReference userdata)
Get the current log output function.- Parameters:
callback
- an SDL_LogOutputFunction filled in with the current log callbackuserdata
- a pointer filled in with the pointer that is passed tocallback
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_LogSetOutputFunction(Pointer, Pointer)
-
SDL_LogSetOutputFunction
public static void SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, com.sun.jna.Pointer userdata)
Replace the default log output function with one of your own.- Parameters:
callback
- an SDL_LogOutputFunction to call instead of the defaultuserdata
- a pointer that is passed tocallback
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_LogGetOutputFunction(PointerByReference, PointerByReference)
-
SDL_LogSetOutputFunction
public static void SDL_LogSetOutputFunction(com.sun.jna.Pointer callback, com.sun.jna.Pointer userdata)
Replace the default log output function with one of your own.- Parameters:
callback
- an SDL_LogOutputFunction to call instead of the defaultuserdata
- a pointer that is passed tocallback
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_LogGetOutputFunction(PointerByReference, PointerByReference)
-
routeSdlLoggingToSlf4j
public static void routeSdlLoggingToSlf4j(com.sun.jna.Pointer userdata, int category, int priority, String message)
Log message handler that will route all SDL internal logging to Java's SLF4J.
Use this method as the first parameter to
SDL_LogSetOutputFunction(SDL_LogOutputFunction, Pointer)
to route all SDL internal logging to Java-style SLF4J. Thus your application can have a single logging backend via a Java de-facto standard SLF4J (LogBack, Log4J 2, etc.). All SDL internal logging will bubble up to Java so that you can configure it as is common in Java.If you want to use this log message handler, you must add SLF4J as a dependency to your project.
Do not call the method directly. Use it as a log message router.
It's not mandatory to use exactly this method. You can use it as an inspiration and write your own router.
Example use in the beginning of your Java app:
SDL_LogSetOutputFunction(SdlLog::routeLibSdlLogToSlf4j, Pointer.NULL); SDL_LogSetAllPriority(SDL_LOG_PRIORITY_VERBOSE);
- Parameters:
userdata
- arbitrary data associated with the logging instance. Not used.category
- will become the logger name for SLF4J.priority
- will become the log priority (trace, debug, info, warn, error).message
- will become the actual message to be logged.
-
-