ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/core/loggers/ScreenLogger.java
Revision: 1.4
Committed: Sun Feb 25 20:34:16 2001 UTC (23 years, 2 months ago) by tdb
Branch: MAIN
Changes since 1.3: +6 -28 lines
Log Message:
Big change in the logging structure. The line is now generated in an external
class, FormatName (in the util package), and the verbosity checking is carried
out in the LoggerServant instead of each logger.
This change was made to try and have behaviour in one place, rather than in each
individual logger.

File Contents

# Content
1 //---PACKAGE DECLARATION---
2 package uk.ac.ukc.iscream.core.loggers;
3
4 //---IMPORTS---
5 import uk.ac.ukc.iscream.util.*;
6 import uk.ac.ukc.iscream.core.*;
7 import java.util.Date;
8 import java.text.DateFormat;
9 import java.util.Locale;
10
11 /**
12 * The ScreenLogger is an implementation of the LoggerImpl defined
13 * in the associated interface. It's only purpose is to simply print
14 * all the logging information it receives to the screen.
15 *
16 * @author $Author: ajm4 $
17 * @version $Id: ScreenLogger.java,v 1.3 2000/12/12 18:28:19 ajm4 Exp $
18 */
19 public class ScreenLogger implements LoggerImpl {
20
21 //---FINAL ATTRIBUTES---
22
23 /**
24 * The current CVS revision of this class
25 */
26 public final String REVISION = "$Revision: 1.3 $";
27
28 //---STATIC METHODS---
29
30 //---CONSTRUCTORS---
31
32 /**
33 * Creates a new ScreenLoggerServant.
34 */
35 public ScreenLogger() {
36 write(toString(), Logger.SYSINIT, "started");
37 }
38
39 //---PUBLIC METHODS---
40
41 /**
42 * The write() method takes a message, formats it using the
43 * formatLogLine() method, and then outputs it to the screen
44 * using System.out.println(). The source is usually the
45 * calling object, referenced by `this'. The method has been
46 * made synchronized to avoid it being called by two different
47 * objects and the output ending up merged on the screen.
48 *
49 * @param source A string representation of the calling object.
50 * @param verbosity the verbosity of this message
51 * @param message The text to be logged.
52 */
53 public synchronized void write(String line, int verbosity) {;
54 System.out.println(line);
55 }
56
57 /**
58 * Overrides the {@link java.lang.Object#toString() Object.toString()}
59 * method to provide clean logging (every class should have this).
60 *
61 * This uses the uk.ac.ukc.iscream.util.FormatName class
62 * to format the toString()
63 *
64 * @return the name of this class and its CVS revision
65 */
66 public String toString() {
67 return FormatName.getName(
68 _name,
69 getClass().getName(),
70 REVISION);
71 }
72
73 //---PRIVATE METHODS---
74
75 private void write(String source, int verbosity, String message) {
76 write(FormatName.formatLogLine(source, verbosity, message), verbosity);
77 }
78
79 //---ACCESSOR/MUTATOR METHODS---
80
81 //---ATTRIBUTES---
82
83 /**
84 * This is the friendly identifier of the
85 * component this class is running in.
86 * eg, a Filter may be called "filter1",
87 * If this class does not have an owning
88 * component, a name from the configuration
89 * can be placed here. This name could also
90 * be changed to null for utility classes.
91 */
92 private String _name = Core.NAME;
93
94 //---STATIC ATTRIBUTES---
95
96 }