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 long aDestinationId, String aDestinationName, boolean aSuccessFlag) {
43 if (LOGGER.isLoggable(level)) {
45 .log(level, "event delivered: " + aEvent + ", sequence '" +
46 getSequenceString(aSequence) + "', destinationId " +
47 aDestinationId + ", destinationName '" + aDestinationName +
52 private String getSequenceString(List<Transformation> aSequence) {
53 StringBuffer buf = new StringBuffer();
54 for (int i = 0; i < aSequence.size(); i++) {
58 Transformation transformation = aSequence.get(i);
59 buf.append(transformation.getName());
61 buf.append(transformation.getFromType());
63 buf.append(transformation.getToType());
66 return buf.toString();
70 public void notDelivered(EventInfo aInfo) {
71 if (LOGGER.isLoggable(level)) {
72 LOGGER.log(level, "event not delivered: " + aInfo);