comparison org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/log/FrameworkLogEntry.d @ 83:0628aaa2996c

added osgi FramworkLog
author Frank Benoit <benoit@tionex.de>
date Tue, 14 Apr 2009 13:22:56 +0200
parents
children bbe49769ec18
comparison
equal deleted inserted replaced
82:b2d6122fa189 83:0628aaa2996c
1 /*******************************************************************************
2 * Copyright (c) 2004, 2008 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11
12 module org.eclipse.osgi.framework.log.FrameworkLogEntry;
13
14 import java.lang.all;
15
16 /**
17 * A framework log entry used to log information to a FrameworkLog
18 * @since 3.1
19 * @noextend This class is not intended to be subclassed by clients.
20 */
21 public class FrameworkLogEntry {
22 /**
23 * Severity constant (value 0) indicating this log entry represents the nominal case.
24 * @see #getSeverity()
25 * @since 3.2
26 */
27 public static final int OK = 0;
28
29 /**
30 * Severity constant (bit mask, value 1) indicating this log entry is informational only.
31 * @see #getSeverity()
32 * @since 3.2
33 */
34 public static final int INFO = 0x01;
35
36 /**
37 * Severity constant (bit mask, value 2) indicating this log entry represents a warning.
38 * @see #getSeverity()
39 * @since 3.2
40 */
41 public static final int WARNING = 0x02;
42
43 /**
44 * Severity constant (bit mask, value 4) indicating this log entry represents an error.
45 * @see #getSeverity()
46 * @since 3.2
47 */
48 public static final int ERROR = 0x04;
49
50 /**
51 * Status type severity (bit mask, value 8) indicating this log entry represents a cancellation.
52 * @see #getSeverity()
53 * @since 3.2
54 */
55 public static final int CANCEL = 0x08;
56
57 // It would be nice to rename some of these fields but we cannot change the getter method
58 // names without breaking clients. Changing only the field names would be confusing.
59 //TODO "entry" has another meaning here - title, summary, tag are better names
60 private String entry;
61 private String message;
62 //TODO get rid of this
63 private int stackCode;
64 //TODO: use "reason" or "cause" instead
65 private Throwable throwable;
66 private FrameworkLogEntry[] children;
67 private int severity = 0;
68 private int bundleCode = 0;
69
70 /**
71 * Constructs a new FrameworkLogEntry
72 * @param entry the entry
73 * @param message the message
74 * @param stackCode the stack code
75 * @param throwable the throwable
76 * @param children the children
77 */
78 public this(String entry, String message, int stackCode, Throwable throwable, FrameworkLogEntry[] children) {
79 this.entry = entry;
80 this.message = message;
81 this.stackCode = stackCode;
82 this.throwable = throwable;
83 this.children = children;
84 }
85
86 /**
87 * Constructs a new FrameworkLogEntry
88 * @param entry the entry
89 * @param severity the severity
90 * @param bundleCode the bundle code
91 * @param message the message
92 * @param stackCode the stack code
93 * @param throwable the throwable
94 * @param children the children
95 * @since 3.2
96 */
97 public this(String entry, int severity, int bundleCode, String message, int stackCode, Throwable throwable, FrameworkLogEntry[] children) {
98 this.entry = entry;
99 this.message = message;
100 this.stackCode = stackCode;
101 this.throwable = throwable;
102 this.children = children;
103 this.severity = severity;
104 this.bundleCode = bundleCode;
105 }
106
107 /**
108 *
109 * @return Returns the children.
110 */
111 public FrameworkLogEntry[] getChildren() {
112 return children;
113 }
114
115 /**
116 * @return Returns the entry.
117 */
118 public String getEntry() {
119 return entry;
120 }
121
122 /**
123 * @return Returns the message.
124 */
125 public String getMessage() {
126 return message;
127 }
128
129 /**
130 * @return Returns the stackCode.
131 */
132 public int getStackCode() {
133 return stackCode;
134 }
135
136 /**
137 * @return Returns the throwable.
138 */
139 public Throwable getThrowable() {
140 return throwable;
141 }
142
143 /**
144 * Returns the severity. The severities are as follows (in descending order):
145 * <ul>
146 * <li><code>CANCEL</code> - cancelation occurred</li>
147 * <li><code>ERROR</code> - a serious error (most severe)</li>
148 * <li><code>WARNING</code> - a warning (less severe)</li>
149 * <li><code>INFO</code> - an informational ("fyi") message (least severe)</li>
150 * <li><code>OK</code> - everything is just fine</li>
151 * </ul>
152 * <p>
153 * The severity of a multi-entry log is defined to be the maximum
154 * severity of any of its children, or <code>OK</code> if it has
155 * no children.
156 * </p>
157 *
158 * @return the severity: one of <code>OK</code>, <code>ERROR</code>,
159 * <code>INFO</code>, <code>WARNING</code>, or <code>CANCEL</code>
160 * @since 3.2
161 */
162 public int getSeverity() {
163 return severity;
164 }
165
166 /**
167 * Returns the bundle-specific code describing the outcome.
168 *
169 * @return bundle-specific code
170 * @since 3.2
171 */
172 public int getBundleCode() {
173 return bundleCode;
174 }
175
176 }