public class DefaultLog extends Object
DefaultLog
class is a convenience class for debug and error
logging using the default log javapcm.log.
The JavaPCM library logs messages to this log, but the log can also be used by client
applications. Use the DefualtLog.log
methods to write to this log.
DefaultLog
uses "flag" style log control.
With flag style control, each message is tagged with a flag that specifies the
error message type. Possible flag values are defined in ErrorLog
. Which
messages are logged is based on the log level set in the configuration file.
Configure the Infranet.properties
file to set the levels and enable
logging. The entries are:
0
for none (default).1
for ERROR messages2
for ERROR and WARNING messages3
for ERROR, WARNING, and DEBUG messagestrue
to log all EBufExceptions
(the default is false).Constructor and Description |
---|
DefaultLog() |
Modifier and Type | Method and Description |
---|---|
static boolean |
doLog(int control)
Evaluates the control level to determine whether a log call will result
in a log entry.
|
static InputStream |
getLog()
Retrieves the
DefaultLog as an InputStream . |
static boolean |
isLogInMemory()
Determines if the message logged is stored in memory rather than on disk.
|
static void |
log(int flags,
String message)
Logs information to the default log file.
|
static void |
log(Object src,
int flags,
String message)
Logs information to the default log file.
|
static void |
log(Object src,
int flags,
String message,
byte[] buf)
Logs a message to the log file along with a hex dump of the array of bytes.
|
static void |
log(Object src,
int flags,
String message,
byte[] buf,
int off,
int len)
Logs information to the default log file.
|
static void |
log(Object src,
int flags,
Throwable thrown)
Logs the error message retrieved from the
Throwable object thrown
by an error. |
static void |
log(Object src,
String message)
Logs information to the default log file.
|
static void |
log(String message)
Logs a message to the default log file.
|
static void |
setFlags(int flags)
Sets the
DefaultLog message flag. |
static void |
setName(String name)
Sets the application name.
|
static void |
setPath(String path)
Sets the
DefaultLog file path name. |
static void |
setWriter(Writer writer)
Set alternative log writer.
|
public static void setName(String name)
name
- The name of the application doing the logging.public static void setPath(String path)
DefaultLog
file path name.path
- The new log path.public static void setWriter(Writer writer)
public static void setFlags(int flags)
DefaultLog
message flag.flags
- The message type.public static void log(String message)
message
- The message to log.public static void log(Object src, String message)
src
- The location of the error. For example, a file name and
a line number. If src
is a string, it is used to describe the source.
Otherwise, the name of the object class is used.message
- The message to log.public static void log(int flags, String message)
flags
- The DefaultLog
message type.message
- The message to log.public static void log(Object src, int flags, Throwable thrown)
Throwable
object thrown
by an error.src
- The location of the error. For example, a file name and
a line number. If src
is a string, it is used to describe the source.
Otherwise, the name of the object class is used.flags
- The DefaultLog
message type.thrown
- the thrown error or exception to log.public static void log(Object src, int flags, String message, byte[] buf)
src
- The location of the error. For example, a file name and
a line number. If src
is a string, it is used to describe the source.
Otherwise, the name of the object class is used.flags
- The DefaultLog
message type.message
- The message to log.buf
- The array of bytes to append to the message.public static void log(Object src, int flags, String message, byte[] buf, int off, int len)
src
- The location of the error. For example, a file name and
a line number. If src
is a string, it is used to describe the source.
Otherwise, the name of the object class is used.flags
- The DefaultLog
message type.message
- The message to log.buf
- The array of bytes to append to the message.off
- Offset into the buffer; the position at which to start the hex dump.len
- Number of buf
bytes to log.public static void log(Object src, int flags, String message)
src
- The location of the error. For example, a file name and
a line number. If src
is a string, it is used to describe the source.
Otherwise, the name of the object class is used.flags
- The DefaultLog
message type.message
- The message to log.public static InputStream getLog()
DefaultLog
as an InputStream
.InputStream
of the DefaultLog
object.public static boolean isLogInMemory()
true
if the log is in memory.public static boolean doLog(int control)
control
- The log message flag that would be passed to
the log method.true
if the specified control level permits writing
to the log file.Copyright © 2003, 2023, Oracle and/or its affiliates.