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
(Generate patch)

Comparing projects/cms/source/server/uk/org/iscream/cms/server/core/loggers/ScreenLogger.java (file contents):
Revision 1.2 by ajm, Wed Nov 29 21:27:25 2000 UTC vs.
Revision 1.3 by ajm, Tue Dec 12 18:28:19 2000 UTC

# Line 2 | Line 2
2   package uk.ac.ukc.iscream.core.loggers;
3  
4   //---IMPORTS---
5 < import uk.ac.ukc.iscream.core.LoggerImpl;
6 < import uk.ac.ukc.iscream.core.Logger;
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;
# Line 33 | Line 33 | public class ScreenLogger implements LoggerImpl {
33       * Creates a new ScreenLoggerServant.
34       */
35      public ScreenLogger() {
36 <        _verbosityLevel = Integer.parseInt(System.getProperty("uk.ac.ukc.iscream.Verbosity"));
37 <        write(this.toString(), Logger.SYSINIT, "started");
38 <        write(this.toString(), Logger.SYSMSG, "using verbosity " + _verbosityLevel);
36 >        _verbosityLevel = Integer.parseInt(System.getProperty("uk.ac.ukc.iscream.Verbosity"));
37 >        write(toString(), Logger.SYSINIT, "started");
38 >        write(toString(), Logger.SYSMSG, "using verbosity " + _verbosityLevel);
39      }
40  
41   //---PUBLIC METHODS---
42  
43      /**
44 <         * The write() method takes a message, formats it using the
45 <         * formatLogLine() method, and then outputs it to the screen
46 <         * using System.out.println(). The source is usually the
47 <         * calling object, referenced by `this'. The method has been
48 <         * made synchronized to avoid it being called by two different
49 <         * objects and the output ending up merged on the screen.
50 <         *
51 <         * @param source A string representation of the calling object.
52 <         * @param verbosity the verbosity of this message
53 <         * @param message The text to be logged.
54 <         */  
44 >     * The write() method takes a message, formats it using the
45 >     * formatLogLine() method, and then outputs it to the screen
46 >     * using System.out.println(). The source is usually the
47 >     * calling object, referenced by `this'. The method has been
48 >     * made synchronized to avoid it being called by two different
49 >     * objects and the output ending up merged on the screen.
50 >     *
51 >     * @param source A string representation of the calling object.
52 >     * @param verbosity the verbosity of this message
53 >     * @param message The text to be logged.
54 >     */  
55      public synchronized void write(String source, int verbosity, String message) {
56 <        if (verbosity <= _verbosityLevel) {
57 <                String line = formatLogLine(source, message);
58 <                System.out.println(line);
56 >        if (verbosity <= _verbosityLevel) {
57 >            String line = formatLogLine(source, message);
58 >            System.out.println(line);
59          }
60      }
61        
# Line 63 | Line 63 | public class ScreenLogger implements LoggerImpl {
63       * Overrides the {@link java.lang.Object#toString() Object.toString()}
64       * method to provide clean logging (every class should have this).
65       *
66 +     * This uses the uk.ac.ukc.iscream.util.FormatName class
67 +     * to format the toString()
68 +     *
69       * @return the name of this class and its CVS revision
70       */
71      public String toString() {
72 <        return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")";
73 <        //return "ScreenLogger" + "(" + REVISION.substring(11, REVISION.length() - 2) + ")";
72 >        return FormatName.getName(
73 >            _name,
74 >            getClass().getName(),
75 >            REVISION);
76      }
77 +    
78   //---PRIVATE METHODS---
79  
80 <        /**
81 <         * This method generates a nicely formatted line for the log,
82 <         * including the date/time and the source of the message. The date
83 <         * and time are formatted using the DateFormat class, and the source
84 <         * class is formatted using the toString() method found in every
85 <         * source file. This is then prepended to the message and returned.
86 <         *
87 <         * @param source A string representation of the calling object.
88 <         * @param message The message to be logged.
89 <         * @return The string to be written to the log.
90 <         */
80 >    /**
81 >     * This method generates a nicely formatted line for the log,
82 >     * including the date/time and the source of the message. The date
83 >     * and time are formatted using the DateFormat class, and the source
84 >     * class is formatted using the toString() method found in every
85 >     * source file. This is then prepended to the message and returned.
86 >     *
87 >     * @param source A string representation of the calling object.
88 >     * @param message The message to be logged.
89 >     * @return The string to be written to the log.
90 >     */
91      private String formatLogLine(String source, String message){
92          String date = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(new Date());
93          return "[" + date + "] " + source + ": " + message;
# Line 91 | Line 97 | public class ScreenLogger implements LoggerImpl {
97  
98   //---ATTRIBUTES---
99  
100 <        /**
101 <         * The verbosity level of this instance
102 <         */
103 <        private int _verbosityLevel;
100 >    /**
101 >     * The verbosity level of this instance
102 >     */
103 >    private int _verbosityLevel;
104 >    
105 >    /**
106 >     * This is the friendly identifier of the
107 >     * component this class is running in.
108 >     * eg, a Filter may be called "filter1",
109 >     * If this class does not have an owning
110 >     * component,  a name from the configuration
111 >     * can be placed here.  This name could also
112 >     * be changed to null for utility classes.
113 >     */
114 >    private String _name = Core.NAME;
115      
116   //---STATIC ATTRIBUTES---
117      

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines