Logging
From harmoni
Contents |
Configuration
The HarmoniLoggingManager only has one configuration property:
- 'database_index'
Example:
// :: Set up the DatabaseManager ::
$configuration =& new ConfigurationProperties;
Services::startManagerAsService("DatabaseManager", $context, $configuration);
//Set up the database connection
$databaseManager =& Services::getService("DatabaseManager");
$dbName = "adam_concerto";
$dbID = $databaseManager->addDatabase( new MySQLDatabase("localhost", $dbName,"test","*****") );
$databaseManager->pConnect($dbID);
// :: Set up the Logging Manager ::
$configuration = new ConfigurationProperties;
$configuration->addProperty('database_index', $dbID);
Services::startManagerAsService("LoggingManager", $context, $configuration);
Types
Format Types
The HarmoniLoggingManager supports one format type:
| Domain: | logging |
|---|---|
| Authority: | edu.middlebury |
| Keyword: | AgentsAndNodes |
| Description: |
This type corresponds to the AgentNodeEntryItem class. This entry item is given a category, message/description, and optional node ids by the client creating the entry item. The current Agent ids are requested from the AuthenticateManager by the AgentNodeEntryItem.
Note:
The AgentNodeEntryItem should be made a proper interface so that additional concrete classes can be used for log creation. This change is scheduled for Harmoni 1.0.3 and the format type listed above will at that point officially correspond to the new interface rather than the current concrete class.
The new interface will define the following methods:
- getCategory()
- getDescription()
- getBacktrace()
- getNodeIds()
- getAgentIds()
Priority Types
The HarmoniLoggingManager considers priority types to be arbitrary. It is recommended to use types that help with sorting of event notices, errors, etc.
Some of the priority types you might seen used in Harmoni and Segue:
| Domain: | logging |
|---|---|
| Authority: | edu.middlebury |
| Keyword: | Event_Notice |
| Description: | Normal Events |
| Domain: | logging |
|---|---|
| Authority: | edu.middlebury |
| Keyword: | Error |
| Description: |
| Domain: | logging |
|---|---|
| Authority: | edu.middlebury |
| Keyword: | Uncaught Exception |
| Description: |
| Domain: | logging |
|---|---|
| Authority: | edu.middlebury |
| Keyword: | All |
| Description: | A reading type to select any priority. |
Usage
Writing
Below is a usage example from Segue:
if (Services::serviceRunning("Logging")) {
$loggingManager = Services::getService("Logging");
$log = $loggingManager->getLogForWriting("Segue");
$formatType = new Type("logging", "edu.middlebury", "AgentsAndNodes",
"A format in which the acting Agent[s] and the target nodes affected are specified.");
$priorityType = new Type("logging", "edu.middlebury", "Event_Notice",
"Normal events.");
$item = new AgentNodeEntryItem("Component Modified", $component->getComponentClass()." modified.");
// Add the nodes involved, in this case the node changed as well as the site it is a part of.
$item->addNodeId($component->getQualifierId());
$site = $component->getDirector()->getRootSiteComponent($component->getId());
if (!$component->getQualifierId()->isEqual($site->getQualifierId()))
$item->addNodeId($site->getQualifierId());
$log->appendLogWithTypes($item, $formatType, $priorityType);
}
