cz.cuni.amis.pogamut.base.utils.logging
Class AgentLogger

Package class diagram package AgentLogger
java.lang.Object
  extended by cz.cuni.amis.pogamut.base.utils.logging.AbstractAgentLogger
      extended by cz.cuni.amis.pogamut.base.utils.logging.AgentLogger
All Implemented Interfaces:
IJMXEnabled, IAgentLogger, IJMXAgentLogger

public class AgentLogger
extends AbstractAgentLogger

All logging apis are fine ... but we don't want to have loggers for classes but for instances - therefore we've created our wrapper allowing you to do two things quickly:

  1. log things
  2. create new logger categories
1) that's obvious - it should be easy

2) this may prove crucial for your debugging to have own logger for planner and another for emotions of your agents, etc.

Simply - every Agent instance (starting with the first abstract class AbstractAgent) has instance of this class (which is java.logging.Logger(s) wrapper).

Every agent's component has own LogCategory and you may obtain your own via getCategory() method.

LogCategory serves as a gateway for your log messages, it contains methods as you know them from java.logging API (things like fine(), info(), severe(), log(Level, msg), etc.).

Plus it allows you to obtain new LogHandler instances for that category (if you need to publish log messages from that category somewhere else).

Every LogHandler serves for filtering messages for one category and publishing them into one end (console, file, memory, whatever...).

Additionally every LogCategory has AgentLogger as its parent.

Author:
Jimmy

Field Summary
 
Fields inherited from class cz.cuni.amis.pogamut.base.utils.logging.AbstractAgentLogger
agentId, LOG_CATEGORY_NAME
 
Constructor Summary
AgentLogger(IAgentId agentId)
           
 
Method Summary
 void enableJMX(MBeanServer mBeanServer, ObjectName parent)
          Method for starting the JMX extension of the class.
static ObjectName getJMXAgentLoggerName(ObjectName parent)
           
protected  ILogCategories getLogCategories()
           
 
Methods inherited from class cz.cuni.amis.pogamut.base.utils.logging.AbstractAgentLogger
addDefaultConsoleHandler, addDefaultFileHandler, addDefaultHandler, addDefaultNetworkHandler, addDefaultPublisher, addToAllCategories, addToAllCategories, getAgentId, getCategories, getCategory, getCategory, getDefaultConsoleHandler, getDefaultNetworkHandler, getNetworkLoggerHost, getNetworkLoggerPort, isDefaultConsoleHandler, isDefaultNetworkHandler, removeDefaultConsoleHandler, removeDefaultHandler, removeDefaultNetworkHandler, removeFromAllCategories, setLevel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AgentLogger

@Inject
public AgentLogger(IAgentId agentId)
Method Detail

getJMXAgentLoggerName

public static ObjectName getJMXAgentLoggerName(ObjectName parent)

enableJMX

public void enableJMX(MBeanServer mBeanServer,
                      ObjectName parent)
               throws JMXAlreadyEnabledException,
                      CantStartJMXException
Description copied from interface: IJMXEnabled
Method for starting the JMX extension of the class.

Object should register whatever objects it wants to expose via JMX.

Parameters:
mBeanServer - server where the MBean of agent is registered
parent - parent's ObjectName, should be used as base of name of the registered MBean
Throws:
JMXAlreadyEnabledException
CantStartJMXException

getLogCategories

protected ILogCategories getLogCategories()
Specified by:
getLogCategories in class AbstractAgentLogger


Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.