1 /*
2 * Copyright 2018 SPF4J.
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 org.spf4j.test.log.annotations;
17
18 import java.lang.annotation.ElementType;
19 import java.lang.annotation.Repeatable;
20 import java.lang.annotation.Retention;
21 import java.lang.annotation.RetentionPolicy;
22 import java.lang.annotation.Target;
23 import org.spf4j.log.Level;
24
25 /**
26 * Annotation to specify custom log printout for a particular unit test.
27 *
28 * The default log level is controlled via:
29 *
30 * <p>System properties:</p>
31 * <ul>
32 * <li>
33 * # default root log level when tests executed from IDE. see TestUtils.class for more info.
34 * spf4j.testLog.rootPrintLevelIDE = DEBUG
35 * </li>
36 * <li>
37 * # default root log level.
38 * spf4j.testLog.rootPrintLevel = INFO
39 * </li>
40 * </ul>
41 * <p>Property files: spf4j-test-prtcfg.properties or spf4j-test-prtcfg-ide.properties for ide settings:</p>
42 * <p>[category(package) name]=[LOG_LEVEL](,[greedy])?</p>
43 *
44 *
45 * @author Zoltan Farkas
46 * @see org.spf4j.test.log.annotations
47 */
48 @Retention(RetentionPolicy.RUNTIME)
49 @Target(ElementType.METHOD)
50 @Repeatable(PrintLogsConfigs.class)
51 public @interface PrintLogs {
52 /**
53 * @return the log category to print. ("" is the root category).
54 */
55 String category() default "";
56 /**
57 * @return true if we don't want downstream log handlers to receive any logs from this category.
58 */
59 boolean greedy() default false;
60 /**
61 * @return minimum log level to print.
62 */
63 Level minLevel() default Level.INFO;
64 /**
65 * @return minimum log level to print when running in the IDE.
66 */
67 Level ideMinLevel() default Level.DEBUG;
68 }