New LogMessageExtractorCheck which writes out TXT report of all loggers
[yangtools.git] / common / checkstyle-logging / src / test / java / org / opendaylight / yangtools / checkstyle / CheckLoggingTestClass.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.yangtools.checkstyle;
10
11 import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory;
13
14 // NOTE:  This test class contains intentional checkstyle issues, for CheckstyleTest
15 public class CheckLoggingTestClass {
16     final Logger logger = LoggerFactory.getLogger(CheckstyleTest.class);
17     private static final java.util.logging.Logger LOG2 = java.util.logging.Logger.getGlobal();
18     private static final Logger LOG = LoggerFactory.getLogger(CheckLoggingTestClass.class);
19     public void foo() {
20         try {
21             logger.debug("foo + bar {}", "foo");
22         } catch(Exception e) {
23             e.printStackTrace();
24             System.out.println(e.getMessage());
25             System.err.print(e.getMessage());
26             logger.debug("foo {}", "bar", e);
27             LOG.info("foo {} {}", e.getMessage(), e);
28             // Multi line
29             LOG.info("foo {} "
30                     + "bar {}");
31         }
32     }
33
34     public void bar(String string, IllegalArgumentException e) {
35         LOG.warn("foo", e);
36         LOG.warn("foo {}", e);
37         LOG.warn("foo", string);
38         LOG.warn("foo {}", string);
39         LOG.warn("foo {}", string, e);
40         LOG.warn(
41             "Unable to parse configuration snapshot from {}. Initial config from {} will be IGNORED in this run. " +
42             "Note that subsequent config files may fail due to this problem. " +
43             "Xml markup in this file needs to be fixed, for detailed information see enclosed exception.",
44             string, string, e);
45         LOG.warn("foo" + string);
46         LOG.warn("foo" + "bar");
47         LOG.warn("foo" + "bar" + "bar");
48     }
49 }