mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

neil_a_wilson
01.17.2007 b4bae64723d5797ec0658312f2212dc97bf3c571
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
 */
package org.opends.server.loggers.debug;
 
import org.opends.server.loggers.LogRecord;
import org.opends.server.loggers.LogCategory;
import org.opends.server.loggers.LogLevel;
import org.opends.server.loggers.Logger;
import org.opends.server.types.DebugLogLevel;
import org.opends.server.types.DebugLogCategory;
 
import java.util.Date;
 
/**
 * A DebugLogRecord is reponsible for passing tracing log messages from the
 * individual Loggers to the LogPublishers.
 */
public class DebugLogRecord extends LogRecord
{
  private static long globalSequenceNumber;
 
  /**
   * The category of this record.
   */
  private LogCategory category;
 
  /**
   * The level of this record.
   */
  private LogLevel level;
 
  /**
   * Sequence number.
   */
  private long sequenceNumber;
 
  /**
   * Thread name for thread that issued logging call.
   */
  private String threadName;
 
  /**
   * Thread ID for thread that issued logging call.
   */
  private long threadID;
 
  /**
   * Event time in milliseconds since 1970.
   */
  private Date timestamp;
 
  /**
   * The signature signature.
   */
  private String signature;
 
  /**
   * The arguments objects.
   */
  private Object[] arguments;
 
  /**
   * The source location.
   */
  private String sourceLocation;
 
  /**
   * The stack trace.
   */
  private String stackTrace;
 
  /**
   * Construct a DebugLogRecord with the given values(s).
   * <p>
   * The sequence property will be initialized with a new unique value.
   * These sequence values are allocated in increasing order within a VM.
   * <p>
   * The timestamp property will be initialized to the current time.
   * <p>
   * The thread ID property will be initialized with a unique ID for
   * the current thread.
   * <p>
   * All other properties will be initialized to "null".
   *
   * @param category the category of this logging message.
   * @param level the level of this logging message.
   * @param msg  the raw non-localized logging message (may be null).
   */
  public DebugLogRecord(DebugLogCategory category,
                        DebugLogLevel level,
                        String msg)
  {
    super(msg);
    this.category = category;
    this.level = level;
  }
 
  /**
   * Construct a DebugLogRecord with the given values(s).
   * <p>
   * The sequence property will be initialized with a new unique value.
   * These sequence values are allocated in increasing order within a VM.
   * <p>
   * The timestamp property will be initialized to the current time.
   * <p>
   * The thread ID property will be initialized with a unique ID for
   * the current thread.
   * <p>
   * All other properties will be initialized to "null".
   *
   * @param category the category of this logging message.
   * @param level the level of this logging message.
   * @param logger  the source logger (may be null).
   * @param msg  the raw non-localized logging message (may be null).
   */
  public DebugLogRecord(DebugLogCategory category,
                        DebugLogLevel level,
                        Logger logger,
                        String msg)
  {
    super(logger, msg);
    this.category = category;
    this.level = level;
  }
 
  /**
   * Construct a DebugLogRecord with the given values(s).
   * <p>
   * The sequence property will be initialized with a new unique value.
   * These sequence values are allocated in increasing order within a VM.
   * <p>
   * The timestamp property will be initialized to the current time.
   * <p>
   * The thread ID property will be initialized with a unique ID for
   * the current thread.
   * <p>
   * All other properties will be initialized to "null".
   *
   * @param category the category of this logging message.
   * @param level the level of this logging message.
   * @param caller  the source object (may be null).
   * @param logger  the source logger (may be null).
   * @param msg  the raw non-localized logging message (may be null).
   */
  public DebugLogRecord(LogCategory category,
                        LogLevel level,
                        Object caller,
                        Logger logger,
                        String msg)
  {
    super(caller, logger, msg);
    this.category = category;
    this.level = level;
 
    // Assign a thread ID, name, and a unique sequence number.
    Thread thread= Thread.currentThread();
    threadID = thread.getId();
    threadName = thread.getName();
    sequenceNumber = globalSequenceNumber++;
    timestamp = new Date();
  }
 
  /**
   * Get an identifier for the thread where the message originated.
   * <p>
   * This is a thread identifier within the Java VM and may or
   * may not map to any operating system ID.
   *
   * @return thread ID
   */
  public long getThreadID() {
    return threadID;
  }
 
  /**
   * Set an identifier for the thread where the message originated.
   * @param threadID the thread ID
   */
  public void setThreadID(long threadID) {
    this.threadID = threadID;
  }
 
  /**
   * Get event time in milliseconds since 1970.
   *
   * @return event time in timestamp since 1970
   */
  public Date getTimestamp() {
    return timestamp;
  }
 
  /**
   * Set event time.
   *
   * @param timestamp event time in timestamp since 1970
   */
  public void setTimestamp(Date timestamp) {
    this.timestamp = timestamp;
  }
 
  /**
   * Get the category of this message.
   *
   * @return the log category.
   */
  public LogCategory getCategory()
  {
    return category;
  }
 
  /**
   * Set the category of this message.
   *
   * @param category the log category to set.
   */
  public void setCategory(LogCategory category)
  {
    this.category = category;
  }
 
  /**
   * Get the level of this message.
   *
   * @return the log level.
   */
  public LogLevel getLevel()
  {
    return level;
  }
 
  /**
   * Set the level of this message.
   *
   * @param level the log level to set.
   */
  public void setLevel(LogLevel level)
  {
    this.level = level;
  }
 
  /**
   * Get the thread name that generated this message.
   *
   * @return the thread name.
   */
  public String getThreadName()
  {
    return threadName;
  }
 
  /**
   * Set the thread name that genreated this message.
   *
   * @param threadName the thread name to set.
   */
  public void setThreadName(String threadName)
  {
    this.threadName = threadName;
  }
 
  /**
   * Get the method signature of this message.
   *
   * @return the method signature.
   */
  public String getSignature()
  {
    return signature;
  }
 
  /**
   * Set the method signature of this message.
   *
   * @param signature the method signature to set.
   */
  public void setSignature(String signature)
  {
    this.signature = signature;
  }
 
  /**
   * Get the arguments of this message. Usually the paramter values of a method.
   *
   * @return the arguments.
   */
  public Object[] getArguments()
  {
    return arguments;
  }
 
  /**
   * Set the arguments of this message.
   *
   * @param arguments the arguments to set.
   */
  public void setArguments(Object[] arguments)
  {
    this.arguments = arguments;
  }
 
  /**
   * Get the source location where this message is generated in the format
   * filename:linenumber.
   *
   * @return the source location.
   */
  public String getSourceLocation()
  {
    return sourceLocation;
  }
 
  /**
   * Set the source location where this message is generated.
   *
   * @param sourceLocation the source location string to set.
   */
  public void setSourceLocation(String sourceLocation)
  {
    this.sourceLocation = sourceLocation;
  }
 
  /**
   * Get the strack trace at the point this message is generated.
   *
   * @return the stack trace string.
   */
  public String getStackTrace()
  {
    return stackTrace;
  }
 
  /**
   * Set the stack trace at the point this message is generated.
   *
   * @param stackTrace the stack trace string to set.
   */
  public void setStackTrace(String stackTrace)
  {
    this.stackTrace = stackTrace;
  }
 
  /**
   * Get the sequence number.
   * <p>
   * Sequence numbers are normally assigned in the LogRecord
   * constructor, which assigns unique sequence numbers to
   * each new LogRecord in increasing order.
   *
   * @return the sequence number
   */
  public long getSequenceNumber() {
    return sequenceNumber;
  }
 
  /**
   * Set the sequence number.
   * <p>
   * Sequence numbers are normally assigned in the LogRecord constructor,
   * so it should not normally be necessary to use this signature.
   *
   * @param seq sequence number
   */
  public void setSequenceNumber(long seq) {
    sequenceNumber = seq;
  }
}