2 * Copyright 2005-2011 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.wamblee.xmlrouter.listener;
18 import java.util.List;
19 import java.util.logging.Level;
20 import java.util.logging.Logger;
22 import org.wamblee.xmlrouter.config.Transformation;
25 * Event logger that simply logs to java.util logging.
27 * @author Erik Brakkee
30 public class LoggingEventListener implements EventListener {
31 private static final Logger LOGGER = Logger
32 .getLogger(LoggingEventListener.class.getName());
36 public LoggingEventListener(Level aLevel) {
41 public void delivered(EventInfo aEvent, List<Transformation> aSequence,
42 String aDestinationId, boolean aSuccessFlag) {
43 if (LOGGER.isLoggable(level)) {
44 LOGGER.log(level, "event delivered: " + aEvent + ", sequence '" +
45 getSequenceString(aSequence) + "', destinationId " +
46 aDestinationId + "'");
50 private String getSequenceString(List<Transformation> aSequence) {
51 StringBuffer buf = new StringBuffer();
52 for (int i = 0; i < aSequence.size(); i++) {
56 Transformation transformation = aSequence.get(i);
57 buf.append(transformation.getId());
59 buf.append(transformation.getFromType());
61 buf.append(transformation.getToType());
64 return buf.toString();
68 public void notDelivered(EventInfo aInfo) {
69 if (LOGGER.isLoggable(level)) {
70 LOGGER.log(level, "event not delivered: " + aInfo);