com.stratelia.silverpeas.silvertrace
Class SilverTrace

java.lang.Object
  extended by com.stratelia.silverpeas.silvertrace.SilverTrace

public class SilverTrace
extends Object

SilverTrace is the trace tool used in silverpeas to trace debug, running infos and errors. This is a 'fully' static class. All functions could be called directly and is thread-safe. The trace functions are : debug, info, warn, error, fatal.

Author:
Thierry leroi

Field Summary
static int APPENDER_ALL
          Used to remove all appenders attached to a module
static int APPENDER_CONSOLE
          Appender sending informations on console
static int APPENDER_FILE
          Appender sending informations on file
static int APPENDER_MAIL
          Appender sending informations mail
static int APPENDER_ROLLING_FILE
          Appender sending informations on rolling file
protected static Properties availableModules
           
protected static String errorDir
           
protected static boolean initFinished
           
static String MODULE_ADMIN
          The Admin module's name
static String MODULE_BUS
          The Bus module's name
static String MODULE_COMPONENTS
          The Components module's name
static String MODULE_ERROR_AND_FATAL
          The special output for ERROR and FATAL module's name
static String MODULE_LIBRARIES
          The Libraries module's name
static String MODULE_ROOT
          The silverpeas root module's name
static String MODULE_SPY
          The special output for SPY module's name
static String ROLLING_MODE_DAILY
          The trace file will be copied every day at midnight with the name : FileName.ext.year-mounth-day A new file named FileName.ext is the created and will contains the next day's traces Example : MyFile.txt.2001-07-23
static String ROLLING_MODE_HOUR
          The trace file will be copied every hour with the name : FileName.ext.year-mounth-day-hour A new file named FileName.ext is the created and will contains the next hour's traces Example : MyFile.txt.2001-07-23-18
static String ROLLING_MODE_MONTH
          The trace file will be copied every 1st day of a mounth with the name : FileName.ext.year-mounth A new file named FileName.ext is the created and will contains the next mounth's traces Example : MyFile.txt.2001-07
static String ROLLING_MODE_WEEK
          The trace file will be copied every 1st day of a week with the name : FileName.ext.year-week A new file named FileName.ext is the created and will contains the next week's traces Example : MyFile.txt.2001-34
static String SPY_ACTION_CREATE
          Create action code
static String SPY_ACTION_DELETE
          Delete action code
static String SPY_ACTION_UPDATE
          Update action code
static int TRACE_LEVEL_DEBUG
          Debug-level traces.
static int TRACE_LEVEL_ERROR
          Error-level traces
static int TRACE_LEVEL_FATAL
          Fatal-level traces
static int TRACE_LEVEL_INFO
          Info-level traces
static int TRACE_LEVEL_UNKNOWN
          Used in setTraceLevel to reset a level trace.
static int TRACE_LEVEL_WARN
          Warning-level traces
protected static MsgTrace traceMessages
           
 
Constructor Summary
SilverTrace()
           
 
Method Summary
static void addAppenderConsole(String module, String patternLayout, String consoleName)
          Add a new console appender to the module.
static void addAppenderFile(String module, String patternLayout, String fileName, boolean appendOnFile)
          Add a new file appender to the module.
protected static void addAppenderFromProperties(Properties fileProperties, int appenderNumber, int appenderType)
          Read appender information from a property file and attach it to it's module
static void addAppenderMail(String module, String patternLayout, String mailHost, String mailFrom, String mailTo, String mailSubject)
          Add a new mail appender to the module.
static void addAppenderRollingFile(String module, String patternLayout, String fileName, String rollingMode)
          Add a new rolling file appender to the module.
static void applyProperties(String filePath)
           
static void debug(String module, String classe, String message)
          Trace some debug informations.
static void debug(String module, String classe, String message, String extraInfos)
          Trace some debug informations.
static void debug(String module, String classe, String message, String extraInfos, Throwable ex)
          Trace some debug informations.
static void debug(String module, String classe, String message, Throwable ex)
          Trace some debug informations.
protected static void emergencyTrace(String module, String classe, String msgToTrace, String extraInfos, Throwable ex)
          Method declaration
protected static void emergencyTrace(String msgToTrace, Throwable ex)
          Method declaration
static void error(String module, String classe, String messageID)
          Trace some 'error' informations.
static void error(String module, String classe, String messageID, String extraInfos)
          Trace some 'error' informations.
static void error(String module, String classe, String messageID, String extraInfos, Throwable ex)
          Trace some 'error' informations.
static void error(String module, String classe, String messageID, Throwable ex)
          Trace some 'error' informations.
static void fatal(String module, String classe, String messageID)
          Trace some 'fatal error' informations.
static void fatal(String module, String classe, String messageID, String extraInfos)
          Trace some 'fatal error' informations.
static void fatal(String module, String classe, String messageID, String extraInfos, Throwable ex)
          Trace some 'fatal error' informations.
static void fatal(String module, String classe, String messageID, Throwable ex)
          Trace some 'fatal error' informations.
protected static String formatErrorAndFatalMessage(String module, String classe, String messageID, String extraInfos, Throwable ex)
          Format the trace message for the Error and Fatal specific case
protected static String formatSpyMessage(String spaceId, String instanceId, String objectId, String userId, String actionId)
          Method declaration
protected static String formatTraceMessage(String module, String classe, String messageID, String message, String extraInfos)
          Format the trace message to send to log4j
static Properties getAppender(String module, int typeOfAppender)
          The purpose of this function is just to return informations about an appender for the JSP - Exploitation page This function is subject to change and SHOULD NOT BE USED by any other page or java class...
protected static String getAppenderName(String module, int typeOfAppender)
          Return the name of the appender depending on it's attached module and type
static int getAvailableAppenders(String module)
          The purpose of this function is just to return the available appenders for the JSP - Exploitation page This function is subject to change and SHOULD NOT BE USED by any other page or java class...
static String[] getEndFileTrace(String nbLines)
           
static Properties getModuleList()
          The purpose of this function is just to return the list of available modules to the JSP - Exploitation page This function is subject to change and SHOULD NOT BE USED by any other page or java class...
protected static org.apache.log4j.Logger getModuleLogger(String module)
          Return the category associated to a module
static int getTraceLevel(String module, boolean chained)
          Get the trace level of a module.
static String getTraceMessage(String messageId)
          Returns the message corresponding to the MessageId in the SilverTrace default language
static String getTraceMessage(String messageId, String language)
          Returns the language-dependant message corresponding to the MessageId
static void info(String module, String classe, String messageID)
          Trace some 'info' informations.
static void info(String module, String classe, String messageID, String extraInfos)
          Trace some 'info' informations.
static void info(String module, String classe, String messageID, String extraInfos, Throwable ex)
          Trace some 'info' informations.
static void info(String module, String classe, String messageID, Throwable ex)
          Trace some 'info' informations.
static void initFromProperties(Properties fileProperties)
          Loads the configuration from the properties given in argument.
static void removeAppender(String module, int typeOfAppender)
          Remove appender(s) attached to a module. typeOfAppender could be one value or a mask of multiple appender types
static void resetAll()
          Reset all modules, messages, appenders and all set debug levels.
static void setTraceLevel(String module, int val)
          Set the minimum trace level of a module.
static void spy(String module, String classe, String spaceId, String instanceId, String objectId, String userId, String actionId)
          Trace some actions (create, delete, update) done by a user on an object of an instance in a space.
protected static String translateFileName(String fileName)
          Translate the
static void warn(String module, String classe, String messageID)
          Trace some 'warning' informations.
static void warn(String module, String classe, String messageID, String extraInfos)
          Trace some 'warning' informations.
static void warn(String module, String classe, String messageID, String extraInfos, Throwable ex)
          Trace some 'warning' informations.
static void warn(String module, String classe, String messageID, Throwable ex)
          Trace some 'warning' informations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRACE_LEVEL_UNKNOWN

public static final int TRACE_LEVEL_UNKNOWN
Used in setTraceLevel to reset a level trace.

See Also:
setTraceLevel(java.lang.String, int), getTraceLevel(java.lang.String, boolean), Constant Field Values

TRACE_LEVEL_DEBUG

public static final int TRACE_LEVEL_DEBUG
Debug-level traces.

See Also:
setTraceLevel(java.lang.String, int), getTraceLevel(java.lang.String, boolean), Constant Field Values

TRACE_LEVEL_INFO

public static final int TRACE_LEVEL_INFO
Info-level traces

See Also:
setTraceLevel(java.lang.String, int), getTraceLevel(java.lang.String, boolean), Constant Field Values

TRACE_LEVEL_WARN

public static final int TRACE_LEVEL_WARN
Warning-level traces

See Also:
setTraceLevel(java.lang.String, int), getTraceLevel(java.lang.String, boolean), Constant Field Values

TRACE_LEVEL_ERROR

public static final int TRACE_LEVEL_ERROR
Error-level traces

See Also:
setTraceLevel(java.lang.String, int), getTraceLevel(java.lang.String, boolean), Constant Field Values

TRACE_LEVEL_FATAL

public static final int TRACE_LEVEL_FATAL
Fatal-level traces

See Also:
setTraceLevel(java.lang.String, int), getTraceLevel(java.lang.String, boolean), Constant Field Values

APPENDER_CONSOLE

public static final int APPENDER_CONSOLE
Appender sending informations on console

See Also:
addAppenderConsole(java.lang.String, java.lang.String, java.lang.String), removeAppender(java.lang.String, int), Constant Field Values

APPENDER_FILE

public static final int APPENDER_FILE
Appender sending informations on file

See Also:
addAppenderFile(java.lang.String, java.lang.String, java.lang.String, boolean), removeAppender(java.lang.String, int), Constant Field Values

APPENDER_ROLLING_FILE

public static final int APPENDER_ROLLING_FILE
Appender sending informations on rolling file

See Also:
addAppenderRollingFile(java.lang.String, java.lang.String, java.lang.String, java.lang.String), removeAppender(java.lang.String, int), #ROLLING_MODE_MOUNTH, ROLLING_MODE_WEEK, ROLLING_MODE_DAILY, ROLLING_MODE_HOUR, Constant Field Values

APPENDER_MAIL

public static final int APPENDER_MAIL
Appender sending informations mail

See Also:
addAppenderMail(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String), removeAppender(java.lang.String, int), Constant Field Values

APPENDER_ALL

public static final int APPENDER_ALL
Used to remove all appenders attached to a module

See Also:
removeAppender(java.lang.String, int), Constant Field Values

ROLLING_MODE_MONTH

public static final String ROLLING_MODE_MONTH
The trace file will be copied every 1st day of a mounth with the name : FileName.ext.year-mounth A new file named FileName.ext is the created and will contains the next mounth's traces Example : MyFile.txt.2001-07

See Also:
addAppenderRollingFile(java.lang.String, java.lang.String, java.lang.String, java.lang.String), Constant Field Values

ROLLING_MODE_WEEK

public static final String ROLLING_MODE_WEEK
The trace file will be copied every 1st day of a week with the name : FileName.ext.year-week A new file named FileName.ext is the created and will contains the next week's traces Example : MyFile.txt.2001-34

See Also:
addAppenderRollingFile(java.lang.String, java.lang.String, java.lang.String, java.lang.String), Constant Field Values

ROLLING_MODE_DAILY

public static final String ROLLING_MODE_DAILY
The trace file will be copied every day at midnight with the name : FileName.ext.year-mounth-day A new file named FileName.ext is the created and will contains the next day's traces Example : MyFile.txt.2001-07-23

See Also:
addAppenderRollingFile(java.lang.String, java.lang.String, java.lang.String, java.lang.String), Constant Field Values

ROLLING_MODE_HOUR

public static final String ROLLING_MODE_HOUR
The trace file will be copied every hour with the name : FileName.ext.year-mounth-day-hour A new file named FileName.ext is the created and will contains the next hour's traces Example : MyFile.txt.2001-07-23-18

See Also:
addAppenderRollingFile(java.lang.String, java.lang.String, java.lang.String, java.lang.String), Constant Field Values

MODULE_ROOT

public static final String MODULE_ROOT
The silverpeas root module's name

See Also:
Constant Field Values

MODULE_ERROR_AND_FATAL

public static final String MODULE_ERROR_AND_FATAL
The special output for ERROR and FATAL module's name

See Also:
Constant Field Values

MODULE_SPY

public static final String MODULE_SPY
The special output for SPY module's name

See Also:
Constant Field Values

SPY_ACTION_CREATE

public static final String SPY_ACTION_CREATE
Create action code

See Also:
Constant Field Values

SPY_ACTION_DELETE

public static final String SPY_ACTION_DELETE
Delete action code

See Also:
Constant Field Values

SPY_ACTION_UPDATE

public static final String SPY_ACTION_UPDATE
Update action code

See Also:
Constant Field Values

MODULE_BUS

public static final String MODULE_BUS
The Bus module's name

See Also:
Constant Field Values

MODULE_ADMIN

public static final String MODULE_ADMIN
The Admin module's name

See Also:
Constant Field Values

MODULE_COMPONENTS

public static final String MODULE_COMPONENTS
The Components module's name

See Also:
Constant Field Values

MODULE_LIBRARIES

public static final String MODULE_LIBRARIES
The Libraries module's name

See Also:
Constant Field Values

availableModules

protected static final Properties availableModules

traceMessages

protected static final MsgTrace traceMessages

errorDir

protected static String errorDir

initFinished

protected static boolean initFinished
Constructor Detail

SilverTrace

public SilverTrace()
Method Detail

debug

public static void debug(String module,
                         String classe,
                         String message)
Trace some debug informations. The programmer is free to display the message he wants...

Parameters:
module - the module name (ex : root, bus, outlook, ...)
classe - the short name of the classe that call this function (ex : "MyFavoriteClass") Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")
message - a string that will be displayed in the traces

debug

public static void debug(String module,
                         String classe,
                         String message,
                         String extraInfos)
Trace some debug informations. The programmer is free to display the message he wants... This function have one extra parameter : extraInfos to add additional informations

Parameters:
module - the module name (ex : root, bus, outlook, ...)
classe - the short name of the classe that call this function (ex : "MyFavoriteClass") Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")
message - a string that will be displayed in the traces
extraInfos - some extra-informations that are displayed after the message in parentesis

debug

public static void debug(String module,
                         String classe,
                         String message,
                         Throwable ex)
Trace some debug informations. The programmer is free to display the message he wants... This function have one extra parameters : ex to display an exception

Parameters:
module - the module name (ex : root, bus, outlook, ...)
classe - the short name of the classe that call this function (ex : "MyFavoriteClass") Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")
message - a string that will be displayed in the traces
ex - the exception to trace

debug

public static void debug(String module,
                         String classe,
                         String message,
                         String extraInfos,
                         Throwable ex)
Trace some debug informations. The programmer is free to display the message he wants... This function have two extra parameters : extraInfos to add additional informations ex to display an exception

Parameters:
module - the module name (ex : root, bus, outlook, ...)
classe - the short name of the classe that call this function (ex : "MyFavoriteClass") Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")
message - a string that will be displayed in the traces
extraInfos - some extra-informations that are displayed after the message in parentesis
ex - the exception to trace

info

public static void info(String module,
                        String classe,
                        String messageID)
Trace some 'info' informations. The message MUST BE one of the predefined in the property files. To add some extra infos, use the function with the 4th parameter : extraInfos

Parameters:
module - the module name (ex : root, bus, outlook, ...)
classe - the short name of the classe that call this function (ex : "MyFavoriteClass") Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")
messageID - the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")

info

public static void info(String module,
                        String classe,
                        String messageID,
                        String extraInfos)
Trace some 'info' informations. The message MUST BE one of the predefined in the property files. This function have one extra parameter : extraInfos to add additional informations

Parameters:
module - the module name (ex : root, bus, outlook, ...)
classe - the short name of the classe that call this function (ex : "MyFavoriteClass") Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")
messageID - the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")
extraInfos - some extra-informations that are displayed after the message in parentesis

info

public static void info(String module,
                        String classe,
                        String messageID,
                        Throwable ex)
Trace some 'info' informations. The message MUST BE one of the predefined in the property files. This function have one extra parameters : ex to display an exception

Parameters:
module - the module name (ex : root, bus, outlook, ...)
classe - the short name of the classe that call this function (ex : "MyFavoriteClass") Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")
messageID - the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")
ex - the exception to trace

info

public static void info(String module,
                        String classe,
                        String messageID,
                        String extraInfos,
                        Throwable ex)
Trace some 'info' informations. The message MUST BE one of the predefined in the property files. This function have two extra parameters : extraInfos to add additional informations ex to display an exception

Parameters:
module - the module name (ex : root, bus, outlook, ...)
classe - the short name of the classe that call this function (ex : "MyFavoriteClass") Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")
messageID - the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")
extraInfos - some extra-informations that are displayed after the message in parentesis
ex - the exception to trace

warn

public static void warn(String module,
                        String classe,
                        String messageID)
Trace some 'warning' informations. The message MUST BE one of the predefined in the property files. To add some extra infos, use the function with the 4th parameter : extraInfos

Parameters:
module - the module name (ex : root, bus, outlook, ...)
classe - the short name of the classe that call this function (ex : "MyFavoriteClass") Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")
messageID - the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")

warn

public static void warn(String module,
                        String classe,
                        String messageID,
                        String extraInfos)
Trace some 'warning' informations. The message MUST BE one of the predefined in the property files. This function have one extra parameter : extraInfos to add additional informations

Parameters:
module - the module name (ex : root, bus, outlook, ...)
classe - the short name of the classe that call this function (ex : "MyFavoriteClass") Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")
messageID - the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")
extraInfos - some extra-informations that are displayed after the message in parentesis

warn

public static void warn(String module,
                        String classe,
                        String messageID,
                        Throwable ex)
Trace some 'warning' informations. The message MUST BE one of the predefined in the property files. This function have one extra parameters : ex to display an exception

Parameters:
module - the module name (ex : root, bus, outlook, ...)
classe - the short name of the classe that call this function (ex : "MyFavoriteClass") Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")
messageID - the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")
ex - the exception to trace

warn

public static void warn(String module,
                        String classe,
                        String messageID,
                        String extraInfos,
                        Throwable ex)
Trace some 'warning' informations. The message MUST BE one of the predefined in the property files. This function have two extra parameters : extraInfos to add additional informations ex to display an exception

Parameters:
module - the module name (ex : root, bus, outlook, ...)
classe - the short name of the classe that call this function (ex : "MyFavoriteClass") Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")
messageID - the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")
extraInfos - some extra-informations that are displayed after the message in parentesis
ex - the exception to trace

error

public static void error(String module,
                         String classe,
                         String messageID)
Trace some 'error' informations. The message MUST BE one of the predefined in the property files. To add some extra infos, use the function with the 4th parameter : extraInfos

Parameters:
module - the module name (ex : root, bus, outlook, ...)
classe - the short name of the classe that call this function (ex : "MyFavoriteClass") Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")
messageID - the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")

error

public static void error(String module,
                         String classe,
                         String messageID,
                         String extraInfos)
Trace some 'error' informations. The message MUST BE one of the predefined in the property files. This function have one extra parameter : extraInfos to add additional informations

Parameters:
module - the module name (ex : root, bus, outlook, ...)
classe - the short name of the classe that call this function (ex : "MyFavoriteClass") Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")
messageID - the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")
extraInfos - some extra-informations that are displayed after the message in parentesis

error

public static void error(String module,
                         String classe,
                         String messageID,
                         Throwable ex)
Trace some 'error' informations. The message MUST BE one of the predefined in the property files. This function have one extra parameters : ex to display an exception

Parameters:
module - the module name (ex : root, bus, outlook, ...)
classe - the short name of the classe that call this function (ex : "MyFavoriteClass") Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")
messageID - the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")
ex - the exception to trace

error

public static void error(String module,
                         String classe,
                         String messageID,
                         String extraInfos,
                         Throwable ex)
Trace some 'error' informations. The message MUST BE one of the predefined in the property files. This function have two extra parameters : extraInfos to add additional informations ex to display an exception

Parameters:
module - the module name (ex : root, bus, outlook, ...)
classe - the short name of the classe that call this function (ex : "MyFavoriteClass") Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")
messageID - the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")
extraInfos - some extra-informations that are displayed after the message in parentesis
ex - the exception to trace

fatal

public static void fatal(String module,
                         String classe,
                         String messageID)
Trace some 'fatal error' informations. The message MUST BE one of the predefined in the property files. To add some extra infos, use the function with the 4th parameter : extraInfos

Parameters:
module - the module name (ex : root, bus, outlook, ...)
classe - the short name of the classe that call this function (ex : "MyFavoriteClass") Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")
messageID - the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")

fatal

public static void fatal(String module,
                         String classe,
                         String messageID,
                         String extraInfos)
Trace some 'fatal error' informations. The message MUST BE one of the predefined in the property files. This function have one extra parameter : extraInfos to add additional informations

Parameters:
module - the module name (ex : root, bus, outlook, ...)
classe - the short name of the classe that call this function (ex : "MyFavoriteClass") Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")
messageID - the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")
extraInfos - some extra-informations that are displayed after the message in parentesis

fatal

public static void fatal(String module,
                         String classe,
                         String messageID,
                         Throwable ex)
Trace some 'fatal error' informations. The message MUST BE one of the predefined in the property files. This function have one extra parameters : ex to display an exception

Parameters:
module - the module name (ex : root, bus, outlook, ...)
classe - the short name of the classe that call this function (ex : "MyFavoriteClass") Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")
messageID - the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")
ex - the exception to trace

fatal

public static void fatal(String module,
                         String classe,
                         String messageID,
                         String extraInfos,
                         Throwable ex)
Trace some 'fatal error' informations. The message MUST BE one of the predefined in the property files. This function have two extra parameters : extraInfos to add additional informations ex to display an exception

Parameters:
module - the module name (ex : root, bus, outlook, ...)
classe - the short name of the classe that call this function (ex : "MyFavoriteClass") Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")
messageID - the name of the message to display (ex : "root.MSG_GEN_FILE_NOT_FOUND")
extraInfos - some extra-informations that are displayed after the message in parentesis
ex - the exception to trace

spy

public static void spy(String module,
                       String classe,
                       String spaceId,
                       String instanceId,
                       String objectId,
                       String userId,
                       String actionId)
Trace some actions (create, delete, update) done by a user on an object of an instance in a space.

Parameters:
module - the module name (ex : root, bus, outlook, ...)
classe - the short name of the classe that call this function (ex : "MyFavoriteClass") Could be followed by the function name (ex : "MyFavoriteClass.myFunction()")
spaceId -
instanceId -
objectId - the object (ex. publication) which is created, deleted ou updated.
userId - the user who has created, deleted or updated.
actionId - One of the constants SPY_ACTION_CREATE, SPY_ACTION_DELETE, SPY_ACTION_UPDATE.

resetAll

public static void resetAll()
Reset all modules, messages, appenders and all set debug levels.


applyProperties

public static void applyProperties(String filePath)

initFromProperties

public static void initFromProperties(Properties fileProperties)
Loads the configuration from the properties given in argument.

Parameters:
fileProperties - the properties to merge with the current configuration

setTraceLevel

public static void setTraceLevel(String module,
                                 int val)
Set the minimum trace level of a module. All traces less than val will not be taken into account

Parameters:
module - the module name (ex : root, bus, outlook, ...)
val - the trace level : could be one of the TRACE_LEVEL_... values. Use TRACE_LEVEL_UNKNOWN to remove the level condition for the module.

getTraceLevel

public static int getTraceLevel(String module,
                                boolean chained)
Get the trace level of a module. Depending on the value of chained, it could ask for the inherited trace levels or not.

Parameters:
module - the module name (ex : root, bus, outlook, ...)
chained - if false : return a trace level only if the module have been set with one. Else, return TRACE_LEVEL_UNKNOWN. If true, look for the inherited trace level.
Returns:
the trace level of the module or TRACE_LEVEL_UNKNOWN if the module was not found

addAppenderConsole

public static void addAppenderConsole(String module,
                                      String patternLayout,
                                      String consoleName)
Add a new console appender to the module. If an appender with the same type have been previously set, delete it and replace it with the new created one.

Parameters:
module - the module name (ex : root, bus, outlook, ...)
patternLayout - the things displayed in this appender, could be one of the LAYOUT_... constants
consoleName - Name of the console output. If null or "", "system.out" is used

addAppenderFile

public static void addAppenderFile(String module,
                                   String patternLayout,
                                   String fileName,
                                   boolean appendOnFile)
Add a new file appender to the module. If an appender with the same type have been previously set, delete it and replace it with the new created one.

Parameters:
module - the module name (ex : root, bus, outlook, ...)
patternLayout - the things displayed in this appender, could be one of the LAYOUT_... constants
fileName - full-path name of the file where the trace are written
appendOnFile - true to append at the end of the existing file (if ther is one), false to remove old file before writting

addAppenderRollingFile

public static void addAppenderRollingFile(String module,
                                          String patternLayout,
                                          String fileName,
                                          String rollingMode)
Add a new rolling file appender to the module. If an appender with the same type have been previously set, delete it and replace it with the new created one.

Parameters:
module - the module name (ex : root, bus, outlook, ...)
patternLayout - the things displayed in this appender, could be one of the LAYOUT_... constants
fileName - full-path name of the file where the trace are written
rollingMode - frequency of the rolling file, could be one of the ROLLING_MODE_... constants

addAppenderMail

public static void addAppenderMail(String module,
                                   String patternLayout,
                                   String mailHost,
                                   String mailFrom,
                                   String mailTo,
                                   String mailSubject)
Add a new mail appender to the module. If an appender with the same type have been previously set, delete it and replace it with the new created one. How it works : mails are only sent when an ERROR or FATAL occur. The mail contains the error and the 512 last traces taken into account (ie, higher than the trace level).

Parameters:
module - the module name (ex : root, bus, outlook, ...)
patternLayout - the things displayed in this appender, could be one of the LAYOUT_... constants
mailHost - host name
mailFrom - email of the sender
mailTo - target email, could be multiple targets separeted with comas
mailSubject - subject of the mail

removeAppender

public static void removeAppender(String module,
                                  int typeOfAppender)
Remove appender(s) attached to a module. typeOfAppender could be one value or a mask of multiple appender types

Parameters:
module - the module name (ex : root, bus, outlook, ...)
typeOfAppender - could be a mask of APPENDER_... values or APPENDER_ALL to remove all appenders attached to the module

getModuleList

public static Properties getModuleList()
The purpose of this function is just to return the list of available modules to the JSP - Exploitation page This function is subject to change and SHOULD NOT BE USED by any other page or java class...

Returns:
The list of the modules with pairs (,)

getAvailableAppenders

public static int getAvailableAppenders(String module)
The purpose of this function is just to return the available appenders for the JSP - Exploitation page This function is subject to change and SHOULD NOT BE USED by any other page or java class...

Parameters:
module - the module name (ex : root, bus, outlook, ...)
Returns:
a mask of the appenders set to this module (not containing the herited ones)

getAppender

public static Properties getAppender(String module,
                                     int typeOfAppender)
The purpose of this function is just to return informations about an appender for the JSP - Exploitation page This function is subject to change and SHOULD NOT BE USED by any other page or java class...

Parameters:
module - the module name (ex : root, bus, outlook, ...)
typeOfAppender - the type of appender : one of the APPENDER_... constants
Returns:
A set of properties discribing the attached appender or null if there is no such appender attached to this module

getTraceMessage

public static String getTraceMessage(String messageId)
Returns the message corresponding to the MessageId in the SilverTrace default language

Parameters:
messageId - the message ID (ex. 'admin.MSG_ERR_GENERAL')
Returns:
the message if the SilverTrace default language

getEndFileTrace

public static String[] getEndFileTrace(String nbLines)

getTraceMessage

public static String getTraceMessage(String messageId,
                                     String language)
Returns the language-dependant message corresponding to the MessageId

Parameters:
messageId - the message ID (ex. 'admin.MSG_ERR_GENERAL')
language - the language to display the message in
Returns:
the message if the specified language

formatSpyMessage

protected static String formatSpyMessage(String spaceId,
                                         String instanceId,
                                         String objectId,
                                         String userId,
                                         String actionId)
Method declaration

Parameters:
spaceId -
instanceId -
objectId -
userId -
actionId -
Returns:
See Also:

formatErrorAndFatalMessage

protected static String formatErrorAndFatalMessage(String module,
                                                   String classe,
                                                   String messageID,
                                                   String extraInfos,
                                                   Throwable ex)
Format the trace message for the Error and Fatal specific case

Parameters:
module -
classe -
messageID -
extraInfos -
ex -
Returns:
the built message

formatTraceMessage

protected static String formatTraceMessage(String module,
                                           String classe,
                                           String messageID,
                                           String message,
                                           String extraInfos)
Format the trace message to send to log4j

Parameters:
module -
classe -
messageID -
message -
extraInfos -
Returns:
the built message

translateFileName

protected static String translateFileName(String fileName)
Translate the

Parameters:
fileName -
Returns:

addAppenderFromProperties

protected static void addAppenderFromProperties(Properties fileProperties,
                                                int appenderNumber,
                                                int appenderType)
Read appender information from a property file and attach it to it's module

Parameters:
fileProperties -
appenderNumber -
appenderType -

getModuleLogger

protected static org.apache.log4j.Logger getModuleLogger(String module)
Return the category associated to a module

Parameters:
module -
Returns:

getAppenderName

protected static String getAppenderName(String module,
                                        int typeOfAppender)
Return the name of the appender depending on it's attached module and type

Parameters:
module -
typeOfAppender -
Returns:

emergencyTrace

protected static void emergencyTrace(String msgToTrace,
                                     Throwable ex)
Method declaration

Parameters:
msgToTrace -
ex -
See Also:

emergencyTrace

protected static void emergencyTrace(String module,
                                     String classe,
                                     String msgToTrace,
                                     String extraInfos,
                                     Throwable ex)
Method declaration

Parameters:
module -
classe -
msgToTrace -
extraInfos -
ex -
See Also:


Copyright © 2016 Silverpeas. All Rights Reserved.