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.logging;
18 import java.util.List;
19 import java.util.logging.Level;
20 import java.util.logging.Logger;
22 import javax.print.attribute.standard.Destination;
23 import javax.xml.transform.dom.DOMSource;
25 import org.wamblee.xml.XMLDocument;
26 import org.wamblee.xmlrouter.common.Id;
27 import org.wamblee.xmlrouter.config.Transformation;
30 * Event logger that simply logs to java.util logging.
32 * @author Erik Brakkee
35 public class LoggingEventLogger implements EventLogger {
36 private static final Logger LOGGER = Logger
37 .getLogger(LoggingEventLogger.class.getName());
41 public LoggingEventLogger(Level aLevel) {
46 public void delivered(String aDocType, Id<DOMSource> aEventId,
47 DOMSource aEvent, List<Transformation> aSequence,
48 Id<Destination> aDestination, String aDestinationName,
49 boolean aSuccessFlag) {
50 if (LOGGER.isLoggable(level)) {
51 LOGGER.log(level, "event delivered: document type '" + aDocType +
52 "', eventId " + aEventId + ", event '" +
53 new XMLDocument(aEvent).print(true) + "', sequence '" +
54 getSequenceString(aSequence) + "', destionationId " +
55 aDestination + ", destinationName '" + aDestinationName + "'");
59 private String getSequenceString(List<Transformation> aSequence) {
60 StringBuffer buf = new StringBuffer();
61 for (Transformation transformation : aSequence) {
62 buf.append(transformation.getName());
64 buf.append(transformation.getFromType());
66 buf.append(transformation.getToType());
69 return buf.toString();
73 public void notDelivered(String aDocumentType, Id<DOMSource> aEventId,
75 if (LOGGER.isLoggable(level)) {
76 LOGGER.log(level, "event not delivered: document type '" +
77 aDocumentType + "', eventId " + aEventId + ", event '" +
78 new XMLDocument(aEvent).print(true) + "'");