001    /**
002     *  Licensed to the Apache Software Foundation (ASF) under one or more
003     *  contributor license agreements.  See the NOTICE file distributed with
004     *  this work for additional information regarding copyright ownership.
005     *  The ASF licenses this file to You under the Apache License, Version 2.0
006     *  (the "License"); you may not use this file except in compliance with
007     *  the License.  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    package org.apache.geronimo.system.logging;
018    
019    import java.io.Serializable;
020    
021    /**
022     * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
023     */
024    public interface SystemLog {
025        /**
026         * The most search lines that will ever be returned, no matter what you
027         * ask for.  This is to conserve memory and transfer bandwidth.
028         */
029        public final static int MAX_SEARCH_RESULTS = 1000;
030        /**
031         * Gets the name of the file that configures the log system
032         */
033        String getConfigFileName();
034        /**
035         * Sets the name of the file that the log system should configure itself from.
036         */
037        void setConfigFileName(String fileName);
038        /**
039         * Gets the name of the log level used for the root logger.
040         */
041        String getRootLoggerLevel();
042        /**
043         * Sets the name of the log level used for the root logger.  Legal values
044         * are defined in GeronimoLogging.java (currently TRACE, DEBUG, INFO,
045         * WARN, ERROR, FATAL)
046         */
047        void setRootLoggerLevel(String level);
048        /**
049         * Indicates how often the log system should check to see if its
050         * configuration file has been updated.
051         */
052        int getRefreshPeriodSeconds();
053        /**
054         * Sets how often the log system should check to see if its
055         * configuration file has been updated.
056         */
057        void setRefreshPeriodSeconds(int seconds);
058        /**
059         * Gets the name of all log files used by this log system.  Typically there
060         * is only one, but specialized cases may use more.
061         */
062        String[] getLogFileNames();
063        /**
064         * Searches the log for records matching the specified parameters.  The
065         * maximum results returned will be the lesser of 1000 and the
066         * provided maxResults argument.
067         *
068         * @see #MAX_SEARCH_RESULTS
069         */
070        SearchResults getMatchingItems(String logFile, Integer firstLine, Integer lastLine, String minLevel,
071                                      String regex, int maxResults, boolean includeStackTraces);
072    
073        public static class LogMessage implements Serializable {
074            private final int lineNumber;
075            private final String lineContent;
076    
077            public LogMessage(int lineNumber, String lineContent) {
078                this.lineNumber = lineNumber;
079                this.lineContent = lineContent;
080            }
081    
082            public int getLineNumber() {
083                return lineNumber;
084            }
085    
086            public String getLineContent() {
087                return lineContent;
088            }
089        }
090    
091        public static class SearchResults implements Serializable {
092            private final int lineCount; // total lines in file
093            private final LogMessage[] results;
094            private final boolean capped;
095    
096            public SearchResults(int lineCount, LogMessage[] results, boolean capped) {
097                this.lineCount = lineCount;
098                this.results = results;
099                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    }