1 /* 2 * Copyright 2010-2013 smartics, Kronseder & Reiner GmbH 3 * 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 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 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. 15 */ 16 package de.smartics.testdoc.collect.processor; 17 18 import java.util.logging.Level; 19 import java.util.logging.Logger; 20 21 import javax.lang.model.element.Element; 22 import javax.lang.model.element.ElementKind; 23 import javax.lang.model.element.TypeElement; 24 25 /** 26 * Helper to log annotation processing. 27 * 28 * @author <a href="mailto:robert.reiner@smartics.de">Robert Reiner</a> 29 * @version $Revision:591 $ 30 */ 31 class AnnotationLogHelper 32 { 33 // ********************************* Fields ********************************* 34 35 // --- constants ------------------------------------------------------------ 36 37 // --- members -------------------------------------------------------------- 38 39 /** 40 * The logger to log to. 41 */ 42 private final Logger log; 43 44 /** 45 * The logger to use to log to the processor context. 46 */ 47 private final ProcessorLogHelper processorLog; 48 49 /** 50 * The processing information to add to the logging message. 51 */ 52 private final Object[] logArguments = new Object[3]; 53 54 // ****************************** Initializer ******************************* 55 56 // ****************************** Constructors ****************************** 57 58 /** 59 * Default constructor. 60 * 61 * @param annotation the annotation that is processed. 62 */ 63 AnnotationLogHelper(final Logger log, final ProcessorLogHelper processorLog, final TypeElement annotation) 64 { 65 this.log = log; 66 this.processorLog = processorLog; 67 logArguments[0] = annotation.getQualifiedName(); 68 } 69 70 // ****************************** Inner Classes ***************************** 71 72 // ********************************* Methods ******************************** 73 74 // --- init ----------------------------------------------------------------- 75 76 // --- get&set -------------------------------------------------------------- 77 78 // --- business ------------------------------------------------------------- 79 80 void logProcessingElementEntry(final Element element, final ElementKind kind) 81 { 82 logArguments[1] = element.getSimpleName(); 83 logArguments[2] = kind; 84 log.log(Level.FINER, "{0}: Processing element {1} of type {2}.", 85 logArguments); 86 } 87 88 void logProcessingElementExit() 89 { 90 log.log(Level.FINER, "{0}: Element {1} of type {2} processed.", 91 logArguments); 92 } 93 94 void note(final String message) 95 { 96 processorLog.note(message); 97 } 98 99 void error(final String message) 100 { 101 processorLog.error(message); 102 } 103 104 // --- object basics -------------------------------------------------------- 105 106 }