01: /*
02: * This file or a portion of this file is licensed under the terms of
03: * the Globus Toolkit Public License, found in file ../GTPL, or at
04: * http://www.globus.org/toolkit/download/license.html. This notice must
05: * appear in redistributions of this file, with or without modification.
06: *
07: * Redistributions of this Software, with or without modification, must
08: * reproduce the GTPL in: (1) the Software, or (2) the Documentation or
09: * some other similar material which is provided with the Software (if
10: * any).
11: *
12: * Copyright 1999-2004 University of Chicago and The University of
13: * Southern California. All rights reserved.
14: */
15: package org.griphyn.cPlanner.common;
16:
17: /**
18: * The default callback for the stream gobbler, that logs all the messages to
19: * a particular logging level. By default all the messages are logged onto the
20: * DEBUG level.
21: *
22: * @author Karan Vahi
23: * @version $Revision: 50 $
24: */
25: public class DefaultStreamGobblerCallback implements
26: StreamGobblerCallback {
27:
28: /**
29: * The level on which the messages are to be logged.
30: */
31: private int mLevel;
32:
33: /**
34: * The instance to the logger to log messages.
35: */
36: private LogManager mLogger;
37:
38: /**
39: * The overloaded constructor.
40: *
41: * @param level the level on which to log.
42: */
43: public DefaultStreamGobblerCallback(int level) {
44: //should do a sanity check on the levels
45: mLevel = level;
46: mLogger = LogManager.getInstance();
47: }
48:
49: /**
50: * Callback whenever a line is read from the stream by the StreamGobbler.
51: * The line is logged to the level specified while initializing the
52: * class.
53: *
54: * @param line the line that is read.
55: */
56: public void work(String line) {
57: mLogger.log(line, mLevel);
58: }
59:
60: }
|