Bees v0.5.0 API

bees.core.resource
Class Logger

java.lang.Object
  |
  +--bees.core.Capability
        |
        +--bees.core.resource.LoggerSpec
              |
              +--bees.core.resource.Logger
All Implemented Interfaces:
CapabilitySpec, edu.utah.janosvm.kit.comm.jsi.JSIHandler, edu.utah.janos.io.LogLevel

public final class Logger
extends LoggerSpec
implements edu.utah.janosvm.kit.comm.jsi.JSIHandler

The Logger capability provides logging functionality using another capability that provides an OutputStream. The only real advantage a Logger has over the OutputStream is that it can put an unforgeable prefix on each log entry, which is convenient for sharing log files.


Field Summary
static PermissionSet DEFAULT_PERMISSIONS
          The default permissions for Logger capability.
static Permission LEVEL_PERMISSION
          The permission containing the maximum LogLevel value for this Logger.
static IntegerPermission[] LEVEL_PERMISSIONS
          An array of IntegerPermissions corresponding to each LogLevel.
static EnumerationPair[] LEVEL_TYPES
          An array of EnumerationPairs that map the LogLevel name to the LogLevel integer value.
 
Fields inherited from class bees.core.resource.LoggerSpec
INVALID_LEVEL, LF_BDOMAIN_PREFIX
 
Fields inherited from class bees.core.Capability
DELETE_PERMISSION, id, INVALID_ID
 
Fields inherited from interface edu.utah.janos.io.LogLevel
ALERT, CRIT, DBG, EMERG, ERR, ERROR, INFO, LEVEL_NAMES, MAX, MIN, NOTICE, WARNING
 
Constructor Summary
Logger()
          Construct an empty Logger capability.
 
Method Summary
static Logger currentLogger()
           
protected  void fromBytes(byte[] flattened, CapabilityEnvelope[] sub)
          Bind this capability to the given object.
 void getSuites(edu.utah.janosvm.kit.comm.jsi.JSIMessage jm)
           
 void handleMessage(edu.utah.janosvm.kit.comm.jsi.JSIHandlerContext jhc, edu.utah.janosvm.kit.comm.jsi.JSIMessage jm)
           
static void log(int level, java.lang.String msg)
          Log a message to the default domain logger at a given level of importance.
static void log(int level, java.lang.Throwable th)
          Log a Throwable to the default domain logger at a given level of importance.
static void log(java.lang.String msg)
          Log a message to the default domain logger at the debug level.
static void log(java.lang.Throwable th)
          Log a Throwable to the default domain logger at the EMERGency level.
 void logMessage(int level, java.lang.String msg)
          Log a message at the given level of importance.
 void logMessage(java.lang.String msg)
          Log a message at the debug level.
 void logThrowable(int level, java.lang.Throwable th)
          Log a Throwable at a given level of importance.
 void logThrowable(java.lang.Throwable th)
          Log a Throwable at the EMERGency level.
 edu.utah.janosvm.kit.comm.jsi.JSIHandler resolveSpecifier(edu.utah.janosvm.kit.comm.jsi.JSIMessage jm, edu.utah.janosvm.kit.comm.jsi.JSIPair jp)
           
 void revoke()
          Revoke access to the capability.
static void setCurrent(Logger logger)
          Set the current logger for this Domain.
 void start()
          Start the logger by adding a LogListener to the internal jnodeos Log object.
 java.lang.String toString()
           
 
Methods inherited from class bees.core.resource.LoggerSpec
getFactory, specFromBytes, toBytes
 
Methods inherited from class bees.core.Capability
checkPermission, clear, clonePermission, deleteCapability, equals, fromBytes, revokedPermission, revokePermission, revokePermissions, valid
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LEVEL_PERMISSION

public static final Permission LEVEL_PERMISSION
The permission containing the maximum LogLevel value for this Logger.

LEVEL_PERMISSIONS

public static final IntegerPermission[] LEVEL_PERMISSIONS
An array of IntegerPermissions corresponding to each LogLevel.

LEVEL_TYPES

public static final EnumerationPair[] LEVEL_TYPES
An array of EnumerationPairs that map the LogLevel name to the LogLevel integer value.

DEFAULT_PERMISSIONS

public static final PermissionSet DEFAULT_PERMISSIONS
The default permissions for Logger capability.
Constructor Detail

Logger

public Logger()
Construct an empty Logger capability.
Method Detail

setCurrent

public static void setCurrent(Logger logger)
Set the current logger for this Domain.
Parameters:
logger - The Logger to use as the default log for this Domain.

currentLogger

public static Logger currentLogger()
Returns:
The default Logger for this Domain.

log

public static void log(int level,
                       java.lang.String msg)
Log a message to the default domain logger at a given level of importance.
Parameters:
level - A LogLevel value.
msg - The message to append to the log.

log

public static void log(java.lang.String msg)
Log a message to the default domain logger at the debug level.
Parameters:
msg - The message to append to the log.

log

public static void log(int level,
                       java.lang.Throwable th)
Log a Throwable to the default domain logger at a given level of importance.
Parameters:
level - A LogLevel value.
th - The exception to log.

log

public static void log(java.lang.Throwable th)
Log a Throwable to the default domain logger at the EMERGency level.
Parameters:
th - The exception to log.

revoke

public void revoke()
Description copied from class: Capability
Revoke access to the capability.
Overrides:
revoke in class LoggerSpec
See Also:
Capability.revoke()

fromBytes

protected final void fromBytes(byte[] flattened,
                               CapabilityEnvelope[] sub)
                        throws java.lang.Exception
Description copied from class: Capability
Bind this capability to the given object.
Overrides:
fromBytes in class Capability
See Also:
Capability.fromBytes(byte[], CapabilityEnvelope[])

start

public void start()
Start the logger by adding a LogListener to the internal jnodeos Log object.

XXX This blows...


logMessage

public void logMessage(java.lang.String msg)
Log a message at the debug level.
Parameters:
msg - The message to append to the log.

logMessage

public void logMessage(int level,
                       java.lang.String msg)
                throws java.lang.IllegalArgumentException
Log a message at the given level of importance.
Parameters:
level - A LogLevel value.
msg - The message to append to the log.
Throws:
java.lang.IllegalArgumentException - if the level value is not one specified in the LogLevel interface.

logThrowable

public void logThrowable(java.lang.Throwable th)
Log a Throwable at the EMERGency level.
Parameters:
th - The exception to log.

logThrowable

public void logThrowable(int level,
                         java.lang.Throwable th)
                  throws java.lang.IllegalArgumentException
Log a Throwable at a given level of importance.
Parameters:
level - A LogLevel value.
th - The exception to log.
Throws:
java.lang.IllegalArgumentException - If the level value is invalid.

resolveSpecifier

public edu.utah.janosvm.kit.comm.jsi.JSIHandler resolveSpecifier(edu.utah.janosvm.kit.comm.jsi.JSIMessage jm,
                                                                 edu.utah.janosvm.kit.comm.jsi.JSIPair jp)
Specified by:
resolveSpecifier in interface edu.utah.janosvm.kit.comm.jsi.JSIHandler
See Also:
JSIHandler.resolveSpecifier(JSIMessage, JSIPair)

handleMessage

public void handleMessage(edu.utah.janosvm.kit.comm.jsi.JSIHandlerContext jhc,
                          edu.utah.janosvm.kit.comm.jsi.JSIMessage jm)
Specified by:
handleMessage in interface edu.utah.janosvm.kit.comm.jsi.JSIHandler
See Also:
JSIHandler.handleMessage(JSIHandlerContext, JSIMessage)

getSuites

public void getSuites(edu.utah.janosvm.kit.comm.jsi.JSIMessage jm)
Specified by:
getSuites in interface edu.utah.janosvm.kit.comm.jsi.JSIHandler
See Also:
JSIHandler.getSuites(JSIMessage)

toString

public java.lang.String toString()
Overrides:
toString in class LoggerSpec
See Also:
Object.toString()

Bees v0.5.0 API

This documentation is Copyright (C) 2002 The University of Utah. All Rights Reserved. See the individual source files for distribution terms.
Documentation, software, and mailing lists for Bees v0.5.0 can be found at the Janos Project: http://www.cs.utah.edu/flux/janos/