Project Report: fawkez

Packagesummary org.jcoderz.commons.logging

org.jcoderz.commons.logging.LogViewer

LineHitsNoteSource
1  /*
2   * $Id: LogViewer.java 1011 2008-06-16 17:57:36Z amandel $
3   *
4   * Copyright 2006, The jCoderZ.org Project. All rights reserved.
5   *
6   * Redistribution and use in source and binary forms, with or without
7   * modification, are permitted provided that the following conditions are
8   * met:
9   *
10   *    * Redistributions of source code must retain the above copyright
11   *      notice, this list of conditions and the following disclaimer.
12   *    * Redistributions in binary form must reproduce the above
13   *      copyright notice, this list of conditions and the following
14   *      disclaimer in the documentation and/or other materials
15   *      provided with the distribution.
16   *    * Neither the name of the jCoderZ.org Project nor the names of
17   *      its contributors may be used to endorse or promote products
18   *      derived from this software without specific prior written
19   *      permission.
20   *
21   * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
22   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24   * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS
25   * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
28   * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29   * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30   * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31   * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32   */
33  package org.jcoderz.commons.logging;
34  
35  import java.io.File;
36  import java.io.FileNotFoundException;
37  import java.io.FileOutputStream;
38  import java.io.PrintWriter;
39  import java.util.ArrayList;
40  import java.util.Arrays;
41  import java.util.Iterator;
42  import java.util.List;
43  import java.util.StringTokenizer;
44  
45  import org.apache.commons.cli.CommandLine;
46  import org.apache.commons.cli.GnuParser;
47  import org.apache.commons.cli.HelpFormatter;
48  import org.apache.commons.cli.Option;
49  import org.apache.commons.cli.OptionBuilder;
50  import org.apache.commons.cli.Options;
51  import org.apache.commons.cli.ParseException;
52  import org.jcoderz.commons.ArgumentMalformedException;
53  import org.jcoderz.commons.types.Date;
54  import org.jcoderz.commons.types.Period;
55  
56  
57  
58  /**
59   * This implements a viewer for existing log files. The output generated by
60   * this should never be viewed using this, since the format might be different
61   * to a 'real' log file.
62   *
63 (1) * TODO: A lot of functionality is still to implement (behaviour according to
64   * command line options).
65   *
66   */
67 (2)public final class LogViewer
68        implements Runnable
69  {
70     /** Line separator to be used in output files. */
71100    public static final String LINE_SEPARATOR
72           = System.getProperty("line.separator");
73  
74100    private static final String DEFAULT_DIR = "." + File.separator + "log";
75     private static final String DEFAULT_FILE = "log.out";
76  
77     /** Time interval [ms] used for polling the log file for new data. */
78     private static final int LOGFILE_POLL_INTERVAL = 100;
79  
80100    private static final String [] EMPTY_STRINGS = new String[0];
81  
82     /**
83      * Level for displaying message stack trace.
84      */
85     private static final int LEVEL_MESSAGE_STACKTRACE = 2;
86     /**
87      * Level for displaying exception stack trace.
88      */
89     private static final int LEVEL_EXCEPTION_STACKTRACE = 1;
90     /**
91      * The min length of the date argument.
92      */
93     private static final int DATE_MIN_LEN = 10;
94  
95     /** Number of tokens expected for a period. */
96     private static final int PERIOD_TOKEN_COUNT = 2;
97  
98     /**
99      * Command line options.
100 (3)    * TODO: Extend options and implement usage.
101      *
102      * The way OptionsBuilder is used is as proposed by the authors
103      * of the commonscli package, but cause checkstyle warnings here...
104      */
105100    private static final Option LOGFILE_OPTION = OptionBuilder.hasArg()
106           .withArgName("logfile").withDescription(
107           "open file <logfile> instead of log.out")
108           .withValueSeparator().withLongOpt("logFile").create("F");
109  
110100    private static final Option LOGDIR_OPTION = OptionBuilder.hasArg()
111           .withArgName("logdir").withDescription(
112           "find log files within <logdir> instead of ./log")
113           .withValueSeparator().withLongOpt("logDir").create("D");
114  
115100    private static final Option LINES_OPTION = OptionBuilder.hasArg()
116           .withArgName("lines").withDescription(
117           "display <lines> last log records instead of 25")
118           .withValueSeparator().withLongOpt("lines").create("l");
119  
120100    private static final Option DATE_OPTION = OptionBuilder.hasOptionalArgs()
121           .withArgName("dateFrom,dateTo").withDescription(
122           "display date [and search for given date/timestamp range. "
123           + "The following date formats are supported: "
124           + "<yyyy-MM-dd|yyyy-MM-dd'T'HH:mm:ss'Z'|"
125           + "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'>. One of both dates may be omitted].")
126           .withValueSeparator().withLongOpt("date").create("d");
127  
128100    private static final Option TIME_OPTION = new Option("t", "timestamp",
129           false, "display timestamp.");
130  
131100    private static final Option BATCH_OPTION = new Option("b", "batch", false,
132           "batch mode, terminate if end of log file reached.");
133  
134100    private static final Option OUTFILE_OPTION = OptionBuilder.hasArg()
135           .withArgName("file").withDescription("send output to file")
136           .withValueSeparator().withLongOpt("outfile").create("o");
137  
138100    private static final Option THREADID_OPTION = OptionBuilder.hasOptionalArgs()
139           .withArgName("tid1,tid2,...").withDescription(
140            "display thread id [and filter for given thread ids")
141            .withValueSeparator().withLongOpt("thread").create("T");
142  
143100    private static final Option XML_OPTION
144           = new Option("xml", "output in xml format.");
145  
146100    private static final Option STACKTRACE_OPTION = OptionBuilder.hasArgs()
147           .withArgName("{0|1|2}").withDescription("display stack trace details; "
148           + "0: no stacktrace, 1: only for exceptions (default), "
149           + "2: all stack trace")
150           .withValueSeparator().create("stack");
151  
152100    private static final Option IMPACT_OPTION = OptionBuilder.hasOptionalArgs()
153           .withArgName("bi1,bi2,...").withDescription("display business impact "
154           + "[and filter for given business impact ids]")
155           .withValueSeparator().withLongOpt("impact").create("i");
156  
157100    private static final Option CATEGORY_OPTION = OptionBuilder.hasOptionalArgs()
158           .withArgName("cat1,cat2,...").withDescription("display category "
159           + "[and filter for given categories]")
160           .withValueSeparator().withLongOpt("cat").create("c");
161  
162100    private static final Option LEVEL_OPTION = OptionBuilder.hasOptionalArgs()
163        .withArgName("lev1,lev2,...").withDescription("display log level "
164        + "[and filter for given levels]")
165        .withValueSeparator().withLongOpt("level").create("L");
166  
167100    private static final Option STANDARD_OPTION = OptionBuilder
168           .withDescription("set standard mode, same as -t -i -c -L -stack 1")
169           .withLongOpt("standard").create("s");
170  
171  /*
172        System.err.println(
173           "  -P[id] PID                     "
174              + "display process ID [and search for given process ID]");
175        System.err.println(
176           "  -r[ecno] [MIN[,MAX]]           "
177              + "display record number [and search for given record range]");
178        System.err.println(
179           "  -e[rrordetails] LEVEL          "
180              + "set error details to given level");
181        System.err.println(
182           "  -tr[acedetails] LEVEL          "
183              + "set trace details to given level");
184        System.err.println(
185           "  -s                             "
186              + "standard mode: same as -t -r -P -IP");
187        System.err.println(
188           "  -f[ormats] (e|t)               "
189              + "display only error or trace messages");
190        System.err.println(
191           "  -lev[el] [<lev1>,[<lev2>]]     "
192              + "display message level [and search for given level range]");
193        System.err.println(
194           "  -logger                        display logger name");
195        System.err.println("  -class                         display class name");
196        System.err.println(
197           "  -method                        display method name");
198        System.err.println(
199           "  -enc[oding] <encoding>         "
200              + "define the encoding for standard output,");
201        System.err.println(
202           "                                 "
203              + "e.g. cp437 (PC US) or cp850 (PC latin1 with Euro)");
204        System.err.println(
205           "                                 "
206              + "Note: use CHCP to find out the codepage used by DOS.");
207  
208     -log [-l[ines]=NO]                   - display NO last lines, if
209     NO is -1, ALL lines will be displayed,
210     default: use the last 25 records
211     combine other filter options with -l
212  [-P[id=PID]]                      [with PID]
213  [-X[id=TxID]]                     [with TxID]
214  [-S[essionID=SID]]                [with SID]
215  [-IP]                             [with IP]
216  [-p[rogram=NAME]]                 [with NAME]
217  [-r[ecno]]                        [show record number]
218  [-e[rrordetails]=LEVEL]           [set errordetails to level 'LEVEL']
219  [-tr[acedetails]=LEVEL]           [set tracedetails to level 'LEVEL']
220  [-s]                              [standard: same as -t -r -P -IP]
221  [-f[ormats]=(e|t)]                [choose only error or trace to be
222     displayed]
223  -lev[el] [<lev1>,[<lev2>]]        display message level [and search for
224     given level range]
225  -logger                           display logger name
226  -class                            display class name
227  -method                           display method name
228  -enc[oding] <encoding>            define the encoding for standard,
229  */
230     private PrintWriter mOut;
231  
232     private Options mOptions;
233  
234     private CommandLine mCommandLine;
235     private DisplayOptions mDisplayOptions;
2360    private final List mFilters = new ArrayList();
237     private LogPrinter mDisplay;
238  
239     private LogReader mLogReader;
240  
241     private LogViewer ()
2420    {
2430       installOptions();
2440    }
245  
246     /**
247      * The main entry method. Installs a new instance of this, which reads the
248      * supplied log file.
249      *
250      * @param argv Contains the command line arguments.
251      */
252     public static void main (String[] argv)
253     {
2540       final LogViewer logConsole = new LogViewer();
255  
2560       if (argv.length < 1)
257        {
2580          logConsole.printUsage();
259        }
260        else
261        {
262           try
263           {
2640             logConsole.readCommandLineArgs(argv);
2650             logConsole.init();
2660             logConsole.run();
267           }
2680          catch (Exception ex)
269           {
2700             Throwable th = ex;
2710             System.err.println("Caught exception: " + th);
2720             while (th != null)
273              {
2740                th.printStackTrace();
2750                th = th.getCause();
2760                if (th != null)
277                 {
2780                   System.err.println("Caused by: " + th);
279                 }
280              }
281           }
282           finally
283           {
2840             logConsole.close();
2850          }
286        }
2870    }
288  
289     private void init ()
290           throws ArgumentMalformedException, java.text.ParseException
291     {
2920       initDisplayOptions();
2930       initDisplayFilters();
2940       setInput();
2950       setOutput();
2960       installDisplay();
2970    }
298  
299     private void initDisplayFilters ()
300           throws ArgumentMalformedException, java.text.ParseException
301     {
3020       initThreadIdFilter();
3030       initBusinessImpactFilter();
3040       initCategoryFilter();
3050       initLogLevelFilter();
3060       initPeriodFilter();
3070    }
308  
309     private void initThreadIdFilter ()
310     {
3110       if (mCommandLine.hasOption(THREADID_OPTION.getOpt()))
312        {
3130          final String[] threadIds = parseOptionValues(
314                 mCommandLine.getOptionValues(THREADID_OPTION.getOpt()));
3150          if ((threadIds != null) && (threadIds.length > 0))
316           {
3170             final List ids = new ArrayList();
3180             for (int i = 0; i < threadIds.length; ++i)
319              {
3200                ids.add(Long.valueOf(threadIds[i]));
321              }
3220             mFilters.add(new ThreadIdFilter(ids));
323           }
324        }
3250    }
326  
327     private void initBusinessImpactFilter ()
328     {
3290       if (mCommandLine.hasOption(IMPACT_OPTION.getOpt()))
330        {
3310          final String[] impacts = parseOptionValues(
332                 mCommandLine.getOptionValues(IMPACT_OPTION.getOpt()));
3330          if ((impacts != null) && (impacts.length > 0))
334           {
3350             mFilters.add(new BusinessImpactFilter(Arrays.asList(impacts)));
336           }
337        }
3380    }
339  
340     private void initCategoryFilter ()
341     {
3420       if (mCommandLine.hasOption(CATEGORY_OPTION.getOpt()))
343        {
3440          final String[] cats = parseOptionValues(
345                 mCommandLine.getOptionValues(CATEGORY_OPTION.getOpt()));
3460          if ((cats != null) && (cats.length > 0))
347           {
3480             mFilters.add(new CategoryFilter(Arrays.asList(cats)));
349           }
350        }
3510    }
352  
353     private void initLogLevelFilter ()
354     {
3550       if (mCommandLine.hasOption(LEVEL_OPTION.getOpt()))
356        {
3570          final String[] levels = parseOptionValues(
358                 mCommandLine.getOptionValues(LEVEL_OPTION.getOpt()));
3590          if ((levels != null) && (levels.length > 0))
360           {
3610             mFilters.add(new LevelFilter(Arrays.asList(levels)));
362           }
363        }
3640    }
365  
366     private void initPeriodFilter ()
367           throws ArgumentMalformedException, java.text.ParseException
368     {
3690       if (mCommandLine.hasOption(DATE_OPTION.getOpt()))
370        {
3710          final Period [] periods = getPeriodsFromOptionValues(
372                 mCommandLine.getOptionValues(DATE_OPTION.getOpt()));
3730          if ((periods != null) && (periods.length > 0))
374           {
3750             mFilters.add(new PeriodFilter(periods));
376           }
377        }
3780    }
379  
380     static Period [] getPeriodsFromOptionValues (String [] optionValues)
381           throws ArgumentMalformedException, java.text.ParseException
382     {
383100       Period [] result = new Period[0];
384100       final List vals = new ArrayList();
385100       for (int i = 0; i < optionValues.length; i++)
386        {
387100          final List values = new ArrayList();
388100          final StringTokenizer tokens = new StringTokenizer(
389                 optionValues[i], ",");
390100          while (tokens.hasMoreTokens())
391           {
392100             values.add(tokens.nextToken());
393           }
394  
395100          String dateFrom = null;
396100          String dateTo = null;
397100          if (values.size() != PERIOD_TOKEN_COUNT)
398           {
399100             if (values.size() == 1 && optionValues[i].startsWith(",", 0))
400              {
401100                dateTo = (String) values.get(0);
402              }
403100             else if (values.size() == 1)
404              {
405100                dateFrom = (String) values.get(0);
406              }
407              else
408              {
4090                throw new LoggingException("Illegal time interval has been "
410                       + "specified in the command line " + optionValues[i]);
411              }
412           }
413           else
414           {
415100             dateFrom = (String) values.get(0);
416100             dateTo = (String) values.get(1);
417           }
418  
419100          final Period period = Period.createPeriod(getDateFrom(dateFrom),
420                 getDateTo(dateTo));
421  
422100          vals.add(period);
423        }
424  
425100       result = (Period []) vals.toArray(result);
426  
427100(4)      return result;
428     }
429  
430     static Date getDateFrom (String str)
431           throws java.text.ParseException
432     {
433100       return getDateFromOptValue(str, true);
434     }
435  
436     static Date getDateTo (String str)
437           throws java.text.ParseException
438     {
439100       return getDateFromOptValue(str, false);
440     }
441  
442     static Date getDateFromOptValue (String str, boolean dateFrom)
443           throws java.text.ParseException
444     {
445        final Date result;
446100       if (str == null || str.length() == 0)
447        {
448100          result = dateFrom ? Date.OLD_DATE : Date.FUTURE_DATE;
449        }
450        else
451        {
452100          if (str.length() == DATE_MIN_LEN)
453           {
454100             result = Date.fromString(str + "Z", Date.DATE_FORMAT);
455           }
456100          else if (str.length() == DATE_MIN_LEN + 1)
457           {
458100             result = Date.fromString(str, Date.DATE_FORMAT);
459           }
460           else
461           {
462100             result = Date.fromString(str);
463           }
464        }
465100       return result;
466     }
467  
468     /**
469      * Splits the strings contained within the supplied array into single values.
470      * Each String of <code>optionValues</code> might contain a comma separated
471      * value list, which is split by this.
472      *
473      * @param optionValues
474    *
475      * @return String array containing the split values. Might be null.
476      */
477     private String [] parseOptionValues (final String [] optionValues)
478     {
4790       String[] rc = null;
4800       if (optionValues != null)
481        {
4820          final List values = new ArrayList();
4830          for (int i = 0; i < optionValues.length; ++i)
484           {
4850             final StringTokenizer tokens = new StringTokenizer(
486                    optionValues[i], "\t ,");
4870             while (tokens.hasMoreTokens())
488              {
4890                values.add(tokens.nextToken());
490              }
491           }
4920          rc = (String[]) values.toArray(EMPTY_STRINGS);
493        }
4940       return rc;
495     }
496  
497     /**
498      *
499      */
500 (5)   private void initDisplayOptions ()
501     {
5020       mDisplayOptions = new DisplayOptions();
5030       if (mCommandLine.hasOption(THREADID_OPTION.getOpt()))
504        {
5050          mDisplayOptions.displayThreadId(true);
506        }
5070       if (mCommandLine.hasOption(TIME_OPTION.getOpt()))
508        {
5090          mDisplayOptions.displayTimestamp(true);
510        }
5110       if (mCommandLine.hasOption(DATE_OPTION.getOpt()))
512        {
5130          mDisplayOptions.displayTimestamp(true);
514        }
5150       if (mCommandLine.hasOption(IMPACT_OPTION.getOpt()))
516        {
5170          mDisplayOptions.displayBusinessImpact(true);
518        }
5190       if (mCommandLine.hasOption(CATEGORY_OPTION.getOpt()))
520        {
5210          mDisplayOptions.displayCategory(true);
522        }
5230       if (mCommandLine.hasOption(LEVEL_OPTION.getOpt()))
524        {
5250          mDisplayOptions.displayLoggerLevel(true);
526        }
5270       if (mCommandLine.hasOption(STACKTRACE_OPTION.getOpt()))
528        {
5290          setStackTraceDetails();
530        }
5310       if (mCommandLine.hasOption(STANDARD_OPTION.getOpt()))
532        {
5330          setStandardDisplay(mDisplayOptions);
534        }
5350    }
536  
537     private void setStandardDisplay (final DisplayOptions dp)
538     {
5390       dp.displayTimestamp(true);
5400       dp.displayBusinessImpact(true);
5410       dp.displayCategory(true);
5420       dp.displayLoggerLevel(true);
5430       dp.displayStackTrace(true);
5440       dp.displayMessageStackTrace(false);
5450    }
546  
547     private void setStackTraceDetails ()
548     {
5490       final String[] details = parseOptionValues(
550              mCommandLine.getOptionValues(STACKTRACE_OPTION.getOpt()));
5510       if ((details != null) && (details.length > 0))
552        {
5530          final int level = Integer.parseInt(details[0]);
5540          mDisplayOptions.displayMessageStackTrace(
555                 level >= LEVEL_MESSAGE_STACKTRACE);
5560          mDisplayOptions.displayStackTrace(
557                 level >= LEVEL_EXCEPTION_STACKTRACE);
558        }
5590    }
560  
561     private void setInput ()
562           throws LoggingException
563     {
5640       final String logDir = mCommandLine.getOptionValue(
565              LOGDIR_OPTION.getOpt(), DEFAULT_DIR);
566  
5670       if ((logDir == null) || (logDir.length() == 0))
568        {
5690          throw new LoggingException("Undefined log directory.");
570        }
571  
5720       final String fileName = logDir + File.separator
573              + mCommandLine.getOptionValue(
574                    LOGFILE_OPTION.getOpt(), DEFAULT_FILE);
575  
576        final LogReader logReader;
577        try
578        {
5790          logReader = new LogReader(fileName);
5800          setFilters(logReader);
5810          mLogReader = logReader;
582        }
5830       catch (InstantiationException ex)
584        {
5850          throw new LoggingException("Error instantiating a LogReader for file "
586                 + fileName, ex);
5870       }
5880    }
589  
590     private void setOutput ()
591           throws LoggingException
592     {
5930       if (mCommandLine.hasOption(OUTFILE_OPTION.getOpt()))
594        {
5950          final String fileName = mCommandLine.getOptionValue(
596                 OUTFILE_OPTION.getOpt());
597           try
598           {
5990             final File file = new File(fileName);
6000             mOut = new PrintWriter(new FileOutputStream(file));
601           }
6020          catch (FileNotFoundException ex)
603           {
6040             throw new LoggingException(
605                    "Could not open the output file " + fileName, ex);
6060          }
6070       }
608        else
609        {
6100          mOut = new PrintWriter(System.out);
611        }
6120    }
613  
614     /**
615      * Closes the log console. Closes the output stream.
616      */
617     private void close ()
618     {
6190       if (mOut != null)
620        {
6210          mOut.flush();
6220          mOut.close();
623        }
6240       if (mLogReader != null)
625        {
6260          mLogReader.close();
627        }
6280    }
629  
630     /**
631      * The run method.
632      * Reads the log file and prints the log records until end of file is reached
633      * (batch mode) or until it is terminated.
634      *
635      * @see java.lang.Runnable#run()
636      */
637     public void run ()
638     {
639        try
640        {
6410          if (mCommandLine.hasOption(BATCH_OPTION.getOpt()))
642           {
6430             runBatchMode();
644           }
645           else
646           {
6470             runLiveMode();
648           }
649        }
6500       catch (Exception ex)
651        {
6520          System.err.println("Caught exception while viewing log file: " + ex);
6530          ex.printStackTrace();
6540       }
6550    }
656  
657     /**
658      * Runs the live mode.
659      */
660     private void runLiveMode ()
661     {
662        while (true)
663        {
6640          LogFileEntry logRecord = null;
665  
6660          if (mLogReader.available())
667           {
668              do
669              {
6700                logRecord = mLogReader.readLogFileEntry();
6710                if ((logRecord != null) && (mDisplay != null))
672                 {
6730                   mDisplay.print(mOut, logRecord);
6740                   logRecord.release();
675                 }
676              }
6770             while (logRecord != null);
6780             mOut.flush();
679           }
680  
681           try
682           {
6830             Thread.sleep(LOGFILE_POLL_INTERVAL);
684           }
6850          catch (InterruptedException e)
686           {
687              // ignore
6880          }
6890       }
690     }
691  
692     /**
693      * Runs the batch mode.
694      */
695     private void runBatchMode ()
696     {
6970       LogFileEntry logRecord = null;
698        do
699        {
7000          logRecord = mLogReader.readLogFileEntry();
7010          if ((logRecord != null) && (mDisplay != null))
702           {
7030             mDisplay.print(mOut, logRecord);
7040             logRecord.release();
705           }
706        }
7070       while (logRecord != null);
708  
7090       mOut.flush();
7100    }
711  
712     private void installOptions ()
713     {
7140       mOptions = new Options();
715  
7160       mOptions.addOption(LOGFILE_OPTION);
7170       mOptions.addOption(LOGDIR_OPTION);
718  //      mOptions.addOption(LINES_OPTION);
7190       mOptions.addOption(BATCH_OPTION);
7200       mOptions.addOption(OUTFILE_OPTION);
7210       mOptions.addOption(XML_OPTION);
7220       mOptions.addOption(STACKTRACE_OPTION);
7230       mOptions.addOption(DATE_OPTION);
7240       mOptions.addOption(TIME_OPTION);
7250       mOptions.addOption(THREADID_OPTION);
7260       mOptions.addOption(IMPACT_OPTION);
7270       mOptions.addOption(CATEGORY_OPTION);
7280       mOptions.addOption(LEVEL_OPTION);
7290       mOptions.addOption(STANDARD_OPTION);
7300    }
731  
732     private void readCommandLineArgs (final String[] args)
733           throws ParseException
734     {
7350       mCommandLine = new GnuParser().parse(mOptions, args, true);
7360    }
737  
738     private void installDisplay ()
739           throws LoggingException
740     {
7410       if (mCommandLine.hasOption(XML_OPTION.getOpt()))
742        {
743           try
744           {
7450             mDisplay = new XmlPrinter();
746           }
7470          catch (InstantiationException ex)
748           {
7490             throw new LoggingException("Error instantiating an XmlPrinter", ex);
7500          }
751        }
752        else
753        {
7540          mDisplay = new BasicPrinter();
755        }
7560       mDisplay.setDisplayOptions(mDisplayOptions);
7570    }
758  
759     /**
760      * Sets the filters for the supplied LogReader as specified in the command
761      * line options.
762      *
763      * @param logReader The LogReader for which to set the filters
764      *
765 (6)    * TODO Implement Me
766      */
767     private void setFilters (final LogReader logReader)
768     {
7690       for (final Iterator iter = mFilters.iterator(); iter.hasNext(); )
770        {
7710          logReader.addFilter((Filter) iter.next());
772        }
7730    }
774  
775     private void printUsage ()
776     {
7770       new HelpFormatter().printHelp(
778              "java org.jcoderz.commons.LogViewer", mOptions);
7790    }
780  }

Findings in this File

f (7) method org.jcoderz.commons.logging.LogViewer.<static initializer>() calls static method on instance reference Intended use of return value.
f (8) method org.jcoderz.commons.logging.LogViewer.<static initializer>() calls static method on instance reference Intended use of return value.
f (9) method org.jcoderz.commons.logging.LogViewer.<static initializer>() calls static method on instance reference Intended use of return value.
f (10) method org.jcoderz.commons.logging.LogViewer.<static initializer>() calls static method on instance reference Intended use of return value.
f (11) method org.jcoderz.commons.logging.LogViewer.<static initializer>() calls static method on instance reference Intended use of return value.
f (12) method org.jcoderz.commons.logging.LogViewer.<static initializer>() calls static method on instance reference Intended use of return value.
f (13) method org.jcoderz.commons.logging.LogViewer.<static initializer>() calls static method on instance reference Intended use of return value.
f (14) method org.jcoderz.commons.logging.LogViewer.<static initializer>() calls static method on instance reference Intended use of return value.
f (15) method org.jcoderz.commons.logging.LogViewer.<static initializer>() calls static method on instance reference Intended use of return value.
f (16) method org.jcoderz.commons.logging.LogViewer.<static initializer>() calls static method on instance reference Intended use of return value.
f (17) method org.jcoderz.commons.logging.LogViewer.<static initializer>() calls static method on instance reference Intended use of return value.
f (18) Avoid printStackTrace(); use a logger call instead. main class
f (19) System.out.print is used main class
f (20) System.out.print is used main class
f (21) Avoid printStackTrace(); use a logger call instead. main class
f (22) System.out.print is used main class
i (1) 63 : 0 Comment matches to-do format '(TODO|FIXME|CHECKME)'.
c (2) 67 : 0 Type Javadoc comment is missing an @author tag.
i (3) 100 : 0 Comment matches to-do format '(TODO|FIXME|CHECKME)'.
w (4) 427 : 0 method org.jcoderz.commons.logging.LogViewer.getPeriodsFromOptionValues(String[]) stores return result in local before immediately returning it
c (5) 500 : 12 The method initDisplayOptions() has an NPath complexity of 256
i (6) 765 : 0 Comment matches to-do format '(TODO|FIXME|CHECKME)'.