|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.safs.Log
public class Log
SAFS Debug Log
This class provides an independent logging capability available to both Java and non-Java SAFS clients. Non-Java clients will write to this log through STAF using the STAF QUEUE of a registered "SAFS/TESTLOG" client of this class. Java clients will simply write to the static methods of this Log class.
The class is intended to act as a development, debugging, and troubleshooting log allowing SAFS clients to write detailed information to this separate log that will not clutter the normal log output during production testing.
Typical usage of this class requires the following steps:
a) java org.safs.Log
b) java org.safs.Log 1
c) java org.safs.Log INFO
d) java org.safs.Log -file:c:/safs/data/debuglog.txt
e) java org.safs.Log DEBUG -file:c:/safs/data/debuglog.txt
Example (a) shows launching the debug Log with the default DEBUG log level.
Examples (b) and (c) are examples launching the debug Log with the INFO log level.
The static main method will launch the debug console and receive 'logmsg' messages on it's STAF QUEUE.
Some log levels, like INFO and INDEX, will always log to this class since they are ONLY used during development/maintenance and will never be written to SAFSLOGS. The org.safs.logging.LogUtilities class can also be enabled to forward messages to this class, if that is desirable.
The internal 'message' method will first try to send using STAF using the 'logmsg' method, if that fails, then it will simply do a System.out.println.
The formatted_message is expected to be in the following format:
The debug Log has some special reserved messages:
So, in order to change the level to WARN, do this:
OR
staf local queue queue name SAFS/TESTLOG message LEVELwarn
And to shutdown the debug Log, do this:
| Field Summary | |
|---|---|
static int |
DEBUG
"0" DEBUG log level. |
static boolean |
ENABLED
Enables/Disables the use of this class for performance reasons. |
static int |
ERROR
"6" ERROR log level. |
static int |
GENERIC
"3" GENERIC log level. |
static int |
INDEX
"2" INDEX log level. |
static int |
INFO
"1" INFO log level. |
protected static java.lang.String |
log_processname
|
static int |
PASS
"4" PASS log level. |
static java.lang.String |
SAFS_TESTLOG_CLIENT
"SAFSTESTLOGClient" -- registered STAF Process name for other JVM/processes. |
static java.lang.String |
SAFS_TESTLOG_CLS
"CLS" -- Command to clear lines in the debug console to separate logging sessions. |
static java.lang.String |
SAFS_TESTLOG_FILE
"-file:" -- Command-line prefix to enable output to file. |
static java.lang.String |
SAFS_TESTLOG_HELP
"HELP" -- Command to show the Help info in the debug console. |
static java.lang.String |
SAFS_TESTLOG_LEVEL
"LEVEL" -- root command for setting the log level. |
static java.lang.String |
SAFS_TESTLOG_LIST
"LIST" -- Command to show the Help info in the debug console. |
static java.lang.String |
SAFS_TESTLOG_PROCESS
"SAFS/TESTLOG" - registered STAF Process name for the primary debug console. |
static java.lang.String |
SAFS_TESTLOG_SHUTDOWN
"SHUTDOWN" -- Command to close the debug console and unregister with STAF. |
static java.lang.String |
SAFS_TESTLOG_VARIABLE
"SAFS/TESTLOG/MSG" -- SAFSVARS variable to monitor sent messages. |
protected static java.lang.String[] |
strlevel
|
static int |
WARN
"5" WARN log level. |
| Constructor Summary | |
|---|---|
Log()
|
|
| Method Summary | |
|---|---|
static void |
close()
Doesn't do anything. |
static void |
debug(java.lang.Object msg)
|
static void |
debug(java.lang.Object msg,
java.lang.Exception ex)
|
static void |
error(java.lang.Object msg)
|
static void |
error(java.lang.Object msg,
java.lang.Exception ex)
|
static void |
generic(java.lang.Object msg)
|
static java.lang.String |
getHelp()
Returns the Help text seen in the SAFS/TESTLOG console. |
static int |
getLogLevel()
|
protected static int |
getStrLevel(java.lang.String slevel)
Parse a string log level into its equivalent int log level value. |
static void |
index(java.lang.Object msg)
|
static void |
info(java.lang.Object msg)
|
static void |
info(java.lang.Object msg,
java.lang.Exception ex)
|
static void |
main(java.lang.String[] args)
Run standalone to activate the debug console. |
static void |
message(int local,
java.lang.Object msg)
Purpose: logs using 'logmsg' if that fails, then does System.out.println. |
static void |
pass(java.lang.Object msg)
|
static void |
setDoLogMsg(boolean _doLogMsg)
|
static void |
setHelper(STAFHelper aHelper)
|
static void |
setLogLevel(int loglevel)
|
static void |
setLogProcessName(java.lang.String _processName)
Used to preset a Log processName prior to any STAFHelper initialization. |
static void |
warn(java.lang.Object msg)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static boolean ENABLED
public static final java.lang.String SAFS_TESTLOG_PROCESS
public static final java.lang.String SAFS_TESTLOG_CLIENT
public static final java.lang.String SAFS_TESTLOG_VARIABLE
public static final java.lang.String SAFS_TESTLOG_SHUTDOWN
public static final java.lang.String SAFS_TESTLOG_CLS
public static final java.lang.String SAFS_TESTLOG_LEVEL
public static final java.lang.String SAFS_TESTLOG_LIST
public static final java.lang.String SAFS_TESTLOG_HELP
public static final java.lang.String SAFS_TESTLOG_FILE
public static final int DEBUG
public static final int INFO
public static final int INDEX
public static final int GENERIC
public static final int PASS
public static final int WARN
public static final int ERROR
protected static final java.lang.String[] strlevel
protected static java.lang.String log_processname
| Constructor Detail |
|---|
public Log()
| Method Detail |
|---|
protected static int getStrLevel(java.lang.String slevel)
public static void setLogLevel(int loglevel)
public static int getLogLevel()
public static void setDoLogMsg(boolean _doLogMsg)
public static void message(int local,
java.lang.Object msg)
local, - intmsg, - Object, message to send (.toString() is used)public static void debug(java.lang.Object msg)
public static void info(java.lang.Object msg)
public static void index(java.lang.Object msg)
public static void generic(java.lang.Object msg)
public static void pass(java.lang.Object msg)
public static void warn(java.lang.Object msg)
public static void error(java.lang.Object msg)
public static void error(java.lang.Object msg,
java.lang.Exception ex)
public static void info(java.lang.Object msg,
java.lang.Exception ex)
public static void debug(java.lang.Object msg,
java.lang.Exception ex)
public static void close()
public static java.lang.String getHelp()
public static void main(java.lang.String[] args)
Accepts a command line argument that allows you to specify the initial log level. The format is strictly the numeric log level ("0" thru "6") or the equivalent text ("debug" thru "error").
Examples:
java org.safs.Log 1
java org.safs.Log INFO
Also accepts a command line argument to write log messages to file.
Examples:
And, of course, both command-line arguments can be used in the same call.
public static void setHelper(STAFHelper aHelper)
public static void setLogProcessName(java.lang.String _processName)
_processName -
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||