Top Description Fields Constructors Methods
com.sun.media.jfxmedia.logging

public Class Logger

extends Object
Class Inheritance
Imports
java.lang.annotation.Native

Logger class used for logging that can output to console or file.

How to use logger in Java layer:

// Initialize logger
Logger.init();
// Set logger level
Logger.setLevel(Logger.DEBUG);

// Log some messages
// Use canLog() to check if message can be logged before doing logging. This is done for performance consideration.
if (Logger.canLog(Logger.DEBUG))
  Logger.logMsg(Logger.DEBUG, "Test DEBUG message");
if (Logger.canLog(Logger.INFO))
  Logger.logMsg(Logger.INFO, "Test INFO message");
if (Logger.canLog(Logger.ERROR))
  Logger.logMsg(Logger.ERROR, "Test ERROR message");
if (Logger.canLog(Logger.WARNING))
  Logger.logMsg(Logger.WARNING, "Test WARNING message");
if (Logger.canLog(Logger.DEBUG))
  Logger.logMsg(Logger.DEBUG, "SomeClass", "SomeMethod", "Test DEBUG message");

How to use logger in Native layer:

Note

Set ENABLE_LOGGING to 1 in ProductFlags.h to enable logging in native layer.

In native levels are define as following:
LOGGER_OFF = Logger.OFF
LOGGER_ERROR = Logger.ERROR
LOGGER_WARNING = Logger.WARNING
LOGGER_INFO = Logger.INFO
LOGGER_DEBUG = Logger.DEBUG

Use following macros to log in native level:
LOGGER_LOGMSG() = void logMsg(int level, String msg)
LOGGER_LOGMSG_CM() = void logMsg(int level, String sourceClass, String sourceMethod, String msg)
Examples:
LOGGER_LOGMSG(LOGGER_DEBUG, "Initializing NativeMediaManager");
LOGGER_LOGMSG_CM(LOGGER_DEBUG, "None", "nativeInitNativeMediaManager", "Initializing NativeMediaManager");

Field Summary

Modifier and TypeField and Description
private static int
public static final int
DEBUG

DEBUG is a message level providing tracing information.

public static final int
ERROR

ERROR is a message level indicating a serious failure.

public static final int
INFO

INFO is a message level for informational messages.

private static final Object
public static final int
OFF

OFF is a special level that can be used to turn off logging.

private static long
public static final int
WARNING

WARNING is a message level indicating a potential problem.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static boolean

Returns:

true if message will be logged, false otherwise.
canLog
(int
messgae level
level
)

Checks if message at specific level can be logged.

private static String

Returns:

timestamp
getTimestamp
()

Get timestamp based on current time

public static boolean
initNative()

Initializes logger.

public static void
logMsg(int
message level
level
,
String
message
msg
)

Log message

public static void
logMsg(int
message level
level
,
String
name of class that issued the logging request
sourceClass
,
String
name of method that issued the logging request
sourceMethod
,
String
message
msg
)

Log message

private static native boolean
private static native void
public static void
setLevel(int
logger level
level
)

Sets logger level.

private static void
startLogger()

This must be run in a privileged context

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentLevelback to summary
private static int currentLevel
DEBUGback to summary
public static final int DEBUG

DEBUG is a message level providing tracing information. This level is initialized to 1.

Annotations
@Native
ERRORback to summary
public static final int ERROR

ERROR is a message level indicating a serious failure. This level is initialized to 4.

Annotations
@Native
INFOback to summary
public static final int INFO

INFO is a message level for informational messages. This level is initialized to 2.

Annotations
@Native
lockback to summary
private static final Object lock
OFFback to summary
public static final int OFF

OFF is a special level that can be used to turn off logging. This level is initialized to Integer.MAX_VALUE.

Annotations
@Native
startTimeback to summary
private static long startTime
WARNINGback to summary
public static final int WARNING

WARNING is a message level indicating a potential problem. This level is initialized to 3.

Annotations
@Native

Constructor Detail

Loggerback to summary
private Logger()

Method Detail

canLogback to summary
public static boolean canLog(int level)

Checks if message at specific level can be logged.

Parameters
level:int

messgae level

Returns:boolean

true if message will be logged, false otherwise.

getTimestampback to summary
private static String getTimestamp()

Get timestamp based on current time

Returns:String

timestamp

initNativeback to summary
public static boolean initNative()

Initializes logger. This function should be called once before using any other logger functions.

logMsgback to summary
public static void logMsg(int level, String msg)

Log message

Parameters
level:int

message level

msg:String

message

logMsgback to summary
public static void logMsg(int level, String sourceClass, String sourceMethod, String msg)

Log message

Parameters
level:int

message level

sourceClass:String

name of class that issued the logging request

sourceMethod:String

name of method that issued the logging request

msg:String

message

nativeInitback to summary
private static native boolean nativeInit()
nativeSetNativeLevelback to summary
private static native void nativeSetNativeLevel(int level)
setLevelback to summary
public static void setLevel(int level)

Sets logger level. All messages below logger level will be ignored. For example, if level is set to WARNING, only messages with ERROR and WARNING levels will be logged and messages with INFO and DEBUG levels will be ignored.

Parameters
level:int

logger level

startLoggerback to summary
private static void startLogger()

This must be run in a privileged context