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.impl;
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;
28 import org.wamblee.xmlrouter.logging.EventLogger;
31 * Event logger that simply logs to java.util logging.
33 * @author Erik Brakkee
36 public class LoggingEventLogger implements EventLogger {
37 private static final Logger LOGGER = Logger
38 .getLogger(LoggingEventLogger.class.getName());
42 public LoggingEventLogger(Level aLevel) {
47 public void delivered(String aDocType, Id<DOMSource> aEventId,
48 DOMSource aEvent, List<Transformation> aSequence,
49 Id<Destination> aDestination, String aDestinationName,
50 boolean aSuccessFlag) {
51 if (LOGGER.isLoggable(level)) {
52 LOGGER.log(level, "event delivered: document type '" + aDocType +
53 "', eventId " + aEventId + ", event '" +
54 new XMLDocument(aEvent).print(true) + "', sequence '" +
55 getSequenceString(aSequence) + "', destionationId " +
56 aDestination + ", destinationName '" + aDestinationName + "'");
60 private String getSequenceString(List<Transformation> aSequence) {
61 StringBuffer buf = new StringBuffer();
62 for (Transformation transformation : aSequence) {
63 buf.append(transformation.getName());
65 buf.append(transformation.getFromType());
67 buf.append(transformation.getToType());
70 return buf.toString();
74 public void notDelivered(String aDocumentType, Id<DOMSource> aEventId,
76 if (LOGGER.isLoggable(level)) {
77 LOGGER.log(level, "event not delivered: document type '" +
78 aDocumentType + "', eventId " + aEventId + ", event '" +
79 new XMLDocument(aEvent).print(true) + "'");