svn commit: r615667 - in /lenya/trunk/src: confpatch/log4j-repositorylogger.xconf modules-core/observation/config/cocoon-xconf/repository-logger.xconf modules-core/observation/java/src/org/apache/lenya/cms/observation/RepositoryLogger.java

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
Author: andreas
Date: Sun Jan 27 14:26:08 2008
New Revision: 615667

URL: http://svn.apache.org/viewvc?rev=615667&view=rev
Log:
Introducting repository logger

Added:
    lenya/trunk/src/confpatch/log4j-repositorylogger.xconf
    lenya/trunk/src/modules-core/observation/config/cocoon-xconf/repository-logger.xconf
    lenya/trunk/src/modules-core/observation/java/src/org/apache/lenya/cms/observation/RepositoryLogger.java

Added: lenya/trunk/src/confpatch/log4j-repositorylogger.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/confpatch/log4j-repositorylogger.xconf?rev=615667&view=auto
==============================================================================
--- lenya/trunk/src/confpatch/log4j-repositorylogger.xconf (added)
+++ lenya/trunk/src/confpatch/log4j-repositorylogger.xconf Sun Jan 27 14:26:08 2008
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<xconf xpath="/configuration" unless="/configuration/appender[@name='Repository']" insert-after="appender">
+
+  <appender class="org.apache.log4j.DailyRollingFileAppender" name="Repository">
+    <param name="File" value="${context-root}/WEB-INF/logs/repository.log"/>
+    <param name="DatePattern" value="'.'yyyy-MM-dd'.log'" />
+    <layout class="org.apache.log4j.PatternLayout">
+      <param name="ConversionPattern" value="%d %m%n"/>
+    </layout>     
+  </appender>
+  
+  <logger name="lenya.observation.repositorylogger">
+    <!-- set to "info" to enable repository logging -->
+    <level value="error"/>
+    <appender-ref ref="Repository"/>
+  </logger>
+  
+</xconf>

Added: lenya/trunk/src/modules-core/observation/config/cocoon-xconf/repository-logger.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/observation/config/cocoon-xconf/repository-logger.xconf?rev=615667&view=auto
==============================================================================
--- lenya/trunk/src/modules-core/observation/config/cocoon-xconf/repository-logger.xconf (added)
+++ lenya/trunk/src/modules-core/observation/config/cocoon-xconf/repository-logger.xconf Sun Jan 27 14:26:08 2008
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!-- $Id: usecases-workflow-deactivate.xconf 348547 2005-11-23 20:13:01Z chestnut $ -->
+
+  <xconf xpath="/cocoon" unless="/cocoon/component[@role = 'org.apache.lenya.cms.observation.RepositoryLogger']">
+    <component logger="lenya.observation.repositorylogger"
+      class="org.apache.lenya.cms.observation.RepositoryLogger"
+      role="org.apache.lenya.cms.observation.RepositoryLogger"/>
+  </xconf>

Added: lenya/trunk/src/modules-core/observation/java/src/org/apache/lenya/cms/observation/RepositoryLogger.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/observation/java/src/org/apache/lenya/cms/observation/RepositoryLogger.java?rev=615667&view=auto
==============================================================================
--- lenya/trunk/src/modules-core/observation/java/src/org/apache/lenya/cms/observation/RepositoryLogger.java (added)
+++ lenya/trunk/src/modules-core/observation/java/src/org/apache/lenya/cms/observation/RepositoryLogger.java Sun Jan 27 14:26:08 2008
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.observation;
+
+import org.apache.avalon.framework.activity.Startable;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.thread.ThreadSafe;
+
+/**
+ * Write repository events to the log.
+ */
+public class RepositoryLogger extends AbstractLogEnabled implements RepositoryListener, Startable,
+        Serviceable, ThreadSafe {
+
+    private ServiceManager manager;
+
+    public void eventFired(RepositoryEvent event) {
+        getLogger().info(event.toString());
+    }
+
+    public void start() throws Exception {
+        ObservationRegistry registry = null;
+        try {
+            registry = (ObservationRegistry) this.manager.lookup(ObservationRegistry.ROLE);
+            registry.registerListener(this);
+        } finally {
+            if (registry != null) {
+                this.manager.release(registry);
+            }
+        }
+    }
+
+    public void stop() throws Exception {
+    }
+
+    public void service(ServiceManager manager) throws ServiceException {
+        this.manager = manager;
+    }
+
+}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.