View Javadoc
1   /*
2    * Licensed under the GPL License. You may not use this file except in compliance with the License.
3    * You may obtain a copy of the License at
4    *
5    *   https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
6    *
7    * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
8    * WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
9    * PURPOSE.
10   */
11  package psiprobe.tools.logging;
12  
13  import java.io.File;
14  import java.sql.Timestamp;
15  
16  /**
17   * The Class AbstractLogDestination.
18   */
19  public abstract class AbstractLogDestination extends DefaultAccessor implements LogDestination {
20  
21    @Override
22    public boolean isRoot() {
23      return false;
24    }
25  
26    @Override
27    public boolean isContext() {
28      return false;
29    }
30  
31    @Override
32    public String getIndex() {
33      return null;
34    }
35  
36    @Override
37    public String getConversionPattern() {
38      return null;
39    }
40  
41    /**
42     * Gets the stdout file.
43     *
44     * @return the stdout file
45     */
46    protected File getStdoutFile() {
47      File file = new File(System.getProperty("catalina.base"), "logs/catalina.out");
48      return file.exists() ? file : new File("stdout");
49    }
50  
51    @Override
52    public File getFile() {
53      return getStdoutFile();
54    }
55  
56    @Override
57    public long getSize() {
58      File file = getFile();
59      return file != null && file.exists() ? file.length() : 0;
60    }
61  
62    @Override
63    public Timestamp getLastModified() {
64      File file = getFile();
65      return file != null && file.exists() ? new Timestamp(file.lastModified()) : null;
66    }
67  
68    @Override
69    public String getLevel() {
70      return null;
71    }
72  
73    @Override
74    public String[] getValidLevels() {
75      return new String[0];
76    }
77  
78    @Override
79    public String getEncoding() {
80      return null;
81    }
82  }