Framework Professional Edition Package


com.prosyst.util.ref
Class Log

java.lang.Object
  extended by com.prosyst.util.ref.Log
All Implemented Interfaces:
LogInterface, com.prosyst.util.security.PrivilegedRunner.PrivilegedDispatcher, ServiceTrackerCustomizer
Direct Known Subclasses:
ManagedLog

public class Log
extends java.lang.Object
implements LogInterface, ServiceTrackerCustomizer, com.prosyst.util.security.PrivilegedRunner.PrivilegedDispatcher

Log class is responsible for forwarding bundles's messages to the LogService or console output.


Field Summary
 boolean autoPrintOnConsole
          Flag, pointing whether printing on console should be done if log service is not available
protected  org.osgi.framework.BundleContext bc
          BundleContext to get LogService and service owner of Log object BundleId
 boolean debug
          Deprecated. since osgilib verion 1.3.9 use set/get Debug
 boolean printOnConsole
          Deprecated. since osgilib verion 1.3.9 use set/get PrintOnConsole
protected static com.prosyst.util.security.SecurityUtil securityUtil
           
 
Constructor Summary
Log(org.osgi.framework.BundleContext bc)
           
Log(org.osgi.framework.BundleContext bc, boolean initDebug)
          Constructs a log object, used for logging information in the LogService.
Log(java.lang.String baseName, boolean synch, org.osgi.framework.BundleContext bc)
           
 
Method Summary
 java.lang.Object addingService(org.osgi.framework.ServiceReference reference)
          A service is being added to the ServiceTracker object.
 void close()
          Releases the Log's resources: ungets LogService, removes the ServiceListener from the framework and nulls references.
 void debug(int moduleID, int msgID, java.lang.String msg, java.lang.Throwable t, boolean synch)
          Logs debug messages.
 void debug(int moduleID, int msgID, java.lang.String msg, java.lang.Throwable t, boolean synch, boolean measurement)
          Logs debug messages.
 void debug(int moduleID, int msgID, java.lang.String msg, java.lang.Throwable t, boolean synch, boolean measurement, boolean display)
          Logs debug messages.
 void debug(int moduleID, int msgID, java.lang.String msg, java.lang.Throwable t, boolean synch, boolean measurement, boolean display, boolean logInFile)
          Logs debug messages.
 void debug(java.lang.String str, java.lang.Throwable ex)
          Logs debug information if debug flag is true.
 java.lang.Object dispatchPrivileged(int type, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4)
           
 void error(int moduleID, int msgID, java.lang.String msg, java.lang.Throwable t, boolean synch)
          Logs error messages.
 void error(java.lang.String str, java.lang.Throwable ex)
          Logs error messages.
 void fault(int level, int moduleID, int msgID, java.lang.String msg, java.lang.Throwable t, boolean synch)
           
 void fault(int level, java.lang.String str, java.lang.Throwable exc)
           
 void finalize()
           
 boolean getDebug()
          Gets the flag, which enables logging debug messages.
 boolean getPrintOnConsole()
          Gets the flag, which enables printing log messages on the console.
 void info(int moduleID, int msgID, java.lang.String msg, boolean synch)
          Logs info messages.
 void info(java.lang.String str)
          Logs info messages.
 boolean isAutoPrintOnConsole()
          Checks the auto print on console flag
 boolean isLogErrorLevel()
          Returns whether printing on console should be done for errors (exceptions) and warnings
 void modifiedService(org.osgi.framework.ServiceReference reference, java.lang.Object service)
          A service tracked by the ServiceTracker object has been modified.
 void removedService(org.osgi.framework.ServiceReference reference, java.lang.Object service)
          A service tracked by the ServiceTracker object has been removed.
static boolean security()
           
 void setAutoPrintOnConsole(boolean autoPrintOnConsole)
          Enables/disables auto printing on console.
 void setDebug(boolean value)
          enable/disable loging of debug info
 void setMaps(com.prosyst.util.hash.HashIntObjNS map0, com.prosyst.util.hash.HashIntObjNS starts0)
           
 void setPrintOnConsole(boolean value)
          enable/disable print on console
 void trace(byte[] bytes)
           
 void trace(byte[] bytes, int off, int len)
           
 void trigger(java.lang.String module)
          Forces measurements for process, heap and flash memory.
 void warning(int moduleID, int msgID, java.lang.String msg, java.lang.Throwable t, boolean synch)
          Logs warning messages.
 void warning(java.lang.String str, java.lang.Throwable ex)
          Logs warning messages.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

printOnConsole

public boolean printOnConsole
Deprecated. since osgilib verion 1.3.9 use set/get PrintOnConsole
Flag, pointing if printingOnConsole is allowed


autoPrintOnConsole

public boolean autoPrintOnConsole
Flag, pointing whether printing on console should be done if log service is not available


debug

public boolean debug
Deprecated. since osgilib verion 1.3.9 use set/get Debug
Flag, pointing if logging debuging info is allowed


securityUtil

protected static final com.prosyst.util.security.SecurityUtil securityUtil

bc

protected org.osgi.framework.BundleContext bc
BundleContext to get LogService and service owner of Log object BundleId

Constructor Detail

Log

public Log(org.osgi.framework.BundleContext bc)

Log

public Log(org.osgi.framework.BundleContext bc,
           boolean initDebug)
Constructs a log object, used for logging information in the LogService. If the LogService is unavailble, the information is printed on the server's console.

Parameters:
bc - BundleContext, necessary to get LogService, in case it is started.

Log

public Log(java.lang.String baseName,
           boolean synch,
           org.osgi.framework.BundleContext bc)
Method Detail

error

public void error(java.lang.String str,
                  java.lang.Throwable ex)
Logs error messages. If printOnConsole is true, or if the LogService is unavailable, log info is printed on console.

Specified by:
error in interface LogInterface
Parameters:
str - Message description of the error.
ex - Throwable object, containing the stack trace; may be null.

fault

public void fault(int level,
                  java.lang.String str,
                  java.lang.Throwable exc)

error

public void error(int moduleID,
                  int msgID,
                  java.lang.String msg,
                  java.lang.Throwable t,
                  boolean synch)
Logs error messages. If printOnConsole is true, or if the LogService is unavailable, log info is printed on console.

Parameters:
moduleID -
msgID -
msg - Message description of the error.
t - Throwable object, containing the stack trace; may be null.
synch - Weather tracer to work synchronious or not

fault

public void fault(int level,
                  int moduleID,
                  int msgID,
                  java.lang.String msg,
                  java.lang.Throwable t,
                  boolean synch)

warning

public void warning(java.lang.String str,
                    java.lang.Throwable ex)
Logs warning messages. If printOnConsole is true, or if the LogService is unavailable, log info is printed on console.

Specified by:
warning in interface LogInterface
Parameters:
str - Message description of the error.
ex - Throwable object, containing the stack trace; may be null.

warning

public void warning(int moduleID,
                    int msgID,
                    java.lang.String msg,
                    java.lang.Throwable t,
                    boolean synch)
Logs warning messages. If printOnConsole is true, or if the LogService is unavailable, log info is printed on console.

Parameters:
moduleID -
msgID -
msg - Message description of the error.
t - Throwable object, containing the stack trace; may be null.
synch - Weather tracer to work synchronious or not

info

public void info(java.lang.String str)
Logs info messages. If printOnConsole is true, or if the LogService is unavailable, message is printed on console.

Specified by:
info in interface LogInterface
Parameters:
str - Message to be logged.

info

public void info(int moduleID,
                 int msgID,
                 java.lang.String msg,
                 boolean synch)
Logs info messages. If printOnConsole is true, or if the LogService is unavailable, log info is printed on console.

Parameters:
moduleID -
msgID -
msg - Message description of the error.
synch - Weather tracer to work synchronious or not

debug

public void debug(java.lang.String str,
                  java.lang.Throwable ex)
Logs debug information if debug flag is true. If LogService is unaccessible or printOnConsole flag is true, log info is printed on console.

Specified by:
debug in interface LogInterface
Parameters:
str - Message description.
ex - Throwable object, containing the stack trace; may be null.

debug

public void debug(int moduleID,
                  int msgID,
                  java.lang.String msg,
                  java.lang.Throwable t,
                  boolean synch)
Logs debug messages. If printOnConsole is true, or if the LogService is unavailable, log info is printed on console.

Parameters:
moduleID -
msgID -
msg - Message description of the error.
t - Throwable object, containing the stack trace; may be null.
synch - Indicates whether tracer should log the message synchronously or not

debug

public void debug(int moduleID,
                  int msgID,
                  java.lang.String msg,
                  java.lang.Throwable t,
                  boolean synch,
                  boolean measurement)
Logs debug messages. If printOnConsole is true, or if the LogService is unavailable, log info is printed on console.

Parameters:
moduleID -
msgID -
msg - Message description of the error.
t - Throwable object, containing the stack trace; may be null.
synch - Indicates whether tracer should log the message synchronously or not
measurement - Indicates whether the message is a measurement or not

debug

public void debug(int moduleID,
                  int msgID,
                  java.lang.String msg,
                  java.lang.Throwable t,
                  boolean synch,
                  boolean measurement,
                  boolean display)
Logs debug messages. If printOnConsole is true, or if the LogService is unavailable, log info is printed on console.

Parameters:
moduleID -
msgID -
msg - Message description of the error.
t - Throwable object, containing the stack trace; may be null.
synch - Indicates whether tracer should log the message synchronously or not
measurement - Indicates whether the message is a measurement or not
display - Indicates whether the message should be displayed in native GUI

debug

public void debug(int moduleID,
                  int msgID,
                  java.lang.String msg,
                  java.lang.Throwable t,
                  boolean synch,
                  boolean measurement,
                  boolean display,
                  boolean logInFile)
Logs debug messages. If printOnConsole is true, or if the LogService is unavailable, log info is printed on console.

Parameters:
moduleID -
msgID -
msg - Message description of the error.
t - Throwable object, containing the stack trace; may be null.
synch - Indicates whether tracer should log the message synchronously or not
measurement - Indicates whether the message is a measurement or not
display - Indicates whether the message should be displayed in native GUI
logInFile - Indicates whether the message should be logged into the log file or not. Used for measurements' logs.

trigger

public void trigger(java.lang.String module)
Forces measurements for process, heap and flash memory. If mbs.measurements.heapMemory is set to true then heap memory measurements are performed. If mbs.measurements.processMemory is set to true then process memory measurements are performed. If mbs.measurements.flashMemory is set to true then flash memory measurements (i.e. storage size) are performed.

Parameters:
module - specifies the module, which forced the measurement

close

public void close()
Releases the Log's resources: ungets LogService, removes the ServiceListener from the framework and nulls references. After invocation of this method, this Log object can be used no longer.

Specified by:
close in interface LogInterface

setPrintOnConsole

public void setPrintOnConsole(boolean value)
enable/disable print on console

Specified by:
setPrintOnConsole in interface LogInterface
Parameters:
value - boolean if true enables print on console else disables it

setDebug

public void setDebug(boolean value)
enable/disable loging of debug info

Specified by:
setDebug in interface LogInterface
Parameters:
value - boolean if true enables loging of debug info else disables it

getDebug

public boolean getDebug()
Gets the flag, which enables logging debug messages.

Specified by:
getDebug in interface LogInterface
Returns:
true if debugging is enabled

getPrintOnConsole

public boolean getPrintOnConsole()
Gets the flag, which enables printing log messages on the console.

Specified by:
getPrintOnConsole in interface LogInterface
Returns:
true if printingon console is enabled

addingService

public java.lang.Object addingService(org.osgi.framework.ServiceReference reference)
Description copied from interface: ServiceTrackerCustomizer
A service is being added to the ServiceTracker object.

This method is called before a service which matched the search parameters of the ServiceTracker object is added to it. This method should return the service object to be tracked for this ServiceReference object. The returned service object is stored in the ServiceTracker object and is available from the getService and getServices methods.

Specified by:
addingService in interface ServiceTrackerCustomizer
Parameters:
reference - Reference to service being added to the ServiceTracker object.
Returns:
The service object to be tracked for the ServiceReference object or null if the ServiceReference object should not be tracked.

modifiedService

public void modifiedService(org.osgi.framework.ServiceReference reference,
                            java.lang.Object service)
Description copied from interface: ServiceTrackerCustomizer
A service tracked by the ServiceTracker object has been modified.

This method is called when a service being tracked by the ServiceTracker object has had it properties modified.

Specified by:
modifiedService in interface ServiceTrackerCustomizer
Parameters:
reference - Reference to service that has been modified.
service - The service object for the modified service.

removedService

public void removedService(org.osgi.framework.ServiceReference reference,
                           java.lang.Object service)
Description copied from interface: ServiceTrackerCustomizer
A service tracked by the ServiceTracker object has been removed.

This method is called after a service is no longer being tracked by the ServiceTracker object.

Specified by:
removedService in interface ServiceTrackerCustomizer
Parameters:
reference - Reference to service that has been removed.
service - The service object for the removed service.

setMaps

public void setMaps(com.prosyst.util.hash.HashIntObjNS map0,
                    com.prosyst.util.hash.HashIntObjNS starts0)

security

public static boolean security()

trace

public void trace(byte[] bytes)

trace

public void trace(byte[] bytes,
                  int off,
                  int len)

finalize

public void finalize()
Overrides:
finalize in class java.lang.Object

isAutoPrintOnConsole

public boolean isAutoPrintOnConsole()
Checks the auto print on console flag

Returns:
true, if autoPrintOnConsole is enabled

setAutoPrintOnConsole

public void setAutoPrintOnConsole(boolean autoPrintOnConsole)
Enables/disables auto printing on console. This flag points whether printing on console should be done if log service is not available

Parameters:
autoPrintOnConsole - if true enables auto print on console else disables it.

isLogErrorLevel

public boolean isLogErrorLevel()
Returns whether printing on console should be done for errors (exceptions) and warnings

Returns:
Returns the error log level flag - if true the error and warnings will be print on console

dispatchPrivileged

public java.lang.Object dispatchPrivileged(int type,
                                           java.lang.Object arg1,
                                           java.lang.Object arg2,
                                           java.lang.Object arg3,
                                           java.lang.Object arg4)
                                    throws java.lang.Exception
Specified by:
dispatchPrivileged in interface com.prosyst.util.security.PrivilegedRunner.PrivilegedDispatcher
Parameters:
type - the type of the action
arg1 - parameter 1 - depends on the action type
arg2 - parameter 2 - depends on the action type
arg3 - parameter 3 - depends on the action type
arg4 - parameter 4 - depends on the action type
Returns:
an object which should be returned from the PrivilegedAction.run() method
Throws:
java.lang.Exception - on error
See Also:
PrivilegedRunner.PrivilegedDispatcher.dispatchPrivileged(int, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object)

Framework Professional Edition Package


Copyright © 1999-2007 ProSyst Software GmbH. All Rights Reserved