1
2
3
4
5
6
7
8
9
10
11
12
13
14 package gov.nasa.pds.tools.handler;
15
16 import java.io.IOException;
17 import java.util.logging.FileHandler;
18 import java.util.logging.Formatter;
19 import java.util.logging.Level;
20
21 /***
22 * Class to setup a file handler for the tools logging capability.
23 *
24 * @author mcayanan
25 *
26 */
27 public class ToolsFileHandler extends FileHandler {
28
29 /***
30 * Constructor that does not append to a file and automatically
31 * sets the log level to 'ALL'.
32 *
33 * @param file A file name to store the logging messages. If the file
34 * exists, it will overwrite the existing contents.
35 * @param formatter Formatter to be used to format the log messages.
36 *
37 * @throws SecurityException
38 * @throws IOException
39 */
40 public ToolsFileHandler(String file, Formatter formatter) throws SecurityException, IOException {
41 this(file, false, Level.ALL, formatter);
42 }
43
44 /***
45 * Constructor that does not append to a file.
46 *
47 * @param file A file name to store the logging messages.
48 * @param level Sets the logging level.
49 * @param formatter Formatter to be used to format the log messages.
50 *
51 * @throws SecurityException
52 * @throws IOException
53 */
54 public ToolsFileHandler(String file, Level level, Formatter formatter) throws SecurityException, IOException {
55 this(file, false, level, formatter);
56 }
57
58 /***
59 * Constructor.
60 *
61 * @param file A file name to store the logging messages.
62 * @param append A flag to tell the handler to append to the file or
63 * to overwrite the existing contents.
64 * @param level Sets the logging level.
65 * @param formatter Formatter to be used to format the log messages.
66 *
67 * @throws SecurityException
68 * @throws IOException
69 */
70 public ToolsFileHandler(String file, boolean append, Level level, Formatter formatter) throws SecurityException, IOException {
71 super(file, append);
72 setLevel(level);
73 setFormatter(formatter);
74 }
75
76 }