1
package com.sun.electric.tool.simulation.test;
5
* Copyright (c) 2005 by Sun Microsystems, Inc.
7
* Created on March 18, 2005
11
* Provides user-configurable diagnostic messages to device classes that extend
12
* this class. Initialization messages can be turned on or off for all
13
* <code>Logger</code> descendents. Once a device object is created, the user
14
* can use {@link #setLogSets} and {@link #setLogOthers} to
15
* control the object's individual logging characteristics. In this manner, the
16
* user can enable messages only from particular devices.
18
* @author Tom O'Neill (toneill)
20
public abstract class Logger {
22
/** Whether to report device initialization */
23
private static boolean logInits = false;
25
/** Whether to report set (configure) events */
26
private boolean logSets = false;
28
/** Whether to report events other than set events */
29
private boolean logOthers = false;
31
public String toString() {
32
return "Logger: logSets=" + isLogSets() + ", logOthers="
37
* @return Returns whether to report all device initialization.
39
public static boolean isLogInits() {
44
* Set whether to report initialization of all devices.
47
* whether to report device initialization
49
public static void setLogInits(boolean logInits) {
50
Logger.logInits = logInits;
54
// * Copy the logging state of this object to the destination
57
// * <code>Logger</code> to copy state to
59
// void copyFrom(Logger source) {
60
// logSets = source.logSets;
61
// logOthers = source.logOthers;
65
* @return Returns whether to report set (configure) events
67
public boolean isLogSets() {
72
* Set whether to report set (configure) events, such as voltage setting
75
* whether to report set events
77
public void setLogSets(boolean logSets) {
78
this.logSets = logSets;
82
* @return Returns whether to report occurences other than initialization
85
public boolean isLogOthers() {
90
* Set whether to report occurences other than initialization and set
94
* whether to report occurences other than initialization and set
97
public void setLogOthers(boolean logOthers) {
98
this.logOthers = logOthers;
102
* Set all optional diagnostic messages on or off
105
* whether to print optional diagnostic messages
107
public void setAllLogging(boolean log) {
113
* Display message <code>msg</code> on <code>stdout</code> when
114
* initialization-logging is enabled.
119
protected static void logInit(String msg) {
120
if (isLogInits() == true) {
121
System.out.println(msg);
126
* Display message <code>msg</code> on <code>stdout</code> when
127
* set-logging is enabled.
132
protected void logSet(String msg) {
133
if (isLogSets() == true) {
134
System.out.println(msg);
139
* Display message <code>msg</code> on <code>stdout</code> when "other"
140
* logging is enabled.
145
protected void logOther(String msg) {
146
if (isLogOthers() == true) {
147
System.out.println(msg);