View Javadoc

1   /**
2    *
3    * Copyright 2003-2004 The Apache Software Foundation
4    *
5    *  Licensed under the Apache License, Version 2.0 (the "License");
6    *  you may not use this file except in compliance with the License.
7    *  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   *  Unless required by applicable law or agreed to in writing, software
12   *  distributed under the License is distributed on an "AS IS" BASIS,
13   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   *  See the License for the specific language governing permissions and
15   *  limitations under the License.
16   */
17  package org.apache.geronimo.system.logging;
18  
19  import java.io.Serializable;
20  
21  /**
22   * @version $Rev: 355877 $ $Date: 2005-12-10 18:48:27 -0800 (Sat, 10 Dec 2005) $
23   */
24  public interface SystemLog {
25      /**
26       * The most search lines that will ever be returned, no matter what you
27       * ask for.  This is to conserve memory and transfer bandwidth.
28       */
29      public final static int MAX_SEARCH_RESULTS = 1000;
30      /**
31       * Gets the name of the file that configures the log system
32       */
33      String getConfigFileName();
34      /**
35       * Sets the name of the file that the log system should configure itself from.
36       */
37      void setConfigFileName(String fileName);
38      /**
39       * Gets the name of the log level used for the root logger.
40       */
41      String getRootLoggerLevel();
42      /**
43       * Sets the name of the log level used for the root logger.  Legal values
44       * are defined in GeronimoLogging.java (currently TRACE, DEBUG, INFO,
45       * WARN, ERROR, FATAL)
46       */
47      void setRootLoggerLevel(String level);
48      /**
49       * Indicates how often the log system should check to see if its
50       * configuration file has been updated.
51       */
52      int getRefreshPeriodSeconds();
53      /**
54       * Sets how often the log system should check to see if its
55       * configuration file has been updated.
56       */
57      void setRefreshPeriodSeconds(int seconds);
58      /**
59       * Gets the name of all log files used by this log system.  Typically there
60       * is only one, but specialized cases may use more.
61       */
62      String[] getLogFileNames();
63      /**
64       * Searches the log for records matching the specified parameters.  The
65       * maximum results returned will be the lesser of 1000 and the
66       * provided maxResults argument.
67       *
68       * @see #MAX_SEARCH_RESULTS
69       */
70      SearchResults getMatchingItems(String logFile, Integer firstLine, Integer lastLine, String minLevel,
71                                    String regex, int maxResults, boolean includeStackTraces);
72  
73      public static class LogMessage implements Serializable {
74          private final int lineNumber;
75          private final String lineContent;
76  
77          public LogMessage(int lineNumber, String lineContent) {
78              this.lineNumber = lineNumber;
79              this.lineContent = lineContent;
80          }
81  
82          public int getLineNumber() {
83              return lineNumber;
84          }
85  
86          public String getLineContent() {
87              return lineContent;
88          }
89      }
90  
91      public static class SearchResults implements Serializable {
92          private final int lineCount; // total lines in file
93          private final LogMessage[] results;
94          private final boolean capped;
95  
96          public SearchResults(int lineCount, LogMessage[] results, boolean capped) {
97              this.lineCount = lineCount;
98              this.results = results;
99              this.capped = capped;
100         }
101 
102         public int getLineCount() {
103             return lineCount;
104         }
105 
106         public LogMessage[] getResults() {
107             return results;
108         }
109 
110         public boolean isCapped() {
111             return capped;
112         }
113     }
114 }