View Javadoc
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.Retention;
20  import java.lang.annotation.RetentionPolicy;
21  import java.lang.annotation.Target;
22  import org.spf4j.log.Level;
23  
24  /**
25   * Annotation to specify custom log collection for a particular unit test.
26   * By default all unprinted logs above and including DEBUG level are collected for the purpose of being logged
27   * in case of unit test failure.
28   * @author Zoltan Farkas
29   * @see org.spf4j.test.log.annotations
30   */
31  @Retention(RetentionPolicy.RUNTIME)
32  @Target(ElementType.METHOD)
33  public @interface CollectLogs {
34  
35    /**
36     * The minimum level of logs to collect.
37     */
38    Level minLevel() default Level.DEBUG;
39  
40    /**
41     * Collect logs that have been printed(logged).
42     */
43    boolean collectPrinted() default false;
44  
45    /**
46     * Maximum number of logs to collect.
47     * @return
48     */
49    int nrLogs() default 256;
50  
51    /**
52     * logs to include from collection. by default all categories are.
53     * @return
54     */
55    String includeLogs() default "";
56  
57    /**
58     * logs to exclude from collection.
59     * @return
60     */
61    String[] excludeLogs() default {};
62  }