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