]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.api/src/org/argeo/slc/execution/ExecutionStep.java
Disable trace logging
[gpl/argeo-slc.git] / org.argeo.slc.api / src / org / argeo / slc / execution / ExecutionStep.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.slc.execution;
17
18 import java.io.Serializable;
19 import java.util.Date;
20
21 /**
22 * An atomic step to be notified in during an {@link ExecutionProcess}. Can be a
23 * log or the start/end of a phase, etc.
24 */
25 public class ExecutionStep implements Serializable {
26 private static final long serialVersionUID = 798640526532912161L;
27
28 public final static String PHASE_START = "PHASE_START";
29 public final static String PHASE_END = "PHASE_END";
30 public final static String ERROR = "ERROR";
31 public final static String WARNING = "WARNING";
32 public final static String INFO = "INFO";
33 public final static String DEBUG = "DEBUG";
34 public final static String TRACE = "TRACE";
35
36 /** @deprecated */
37 public final static String START = "START";
38 /** @deprecated */
39 public final static String END = "END";
40
41 // TODO make the fields final and private when we don't need POJO support
42 // anymore (that
43 // is when SlcExecutionStep is removed)
44 protected String type;
45 protected String thread;
46 protected Date timestamp;
47 protected String log;
48
49 private String location;
50
51 /** Empty constructor */
52 public ExecutionStep() {
53 Thread currentThread = Thread.currentThread();
54 thread = currentThread.getName();
55 }
56
57 /** Creates a step at the current date */
58 public ExecutionStep(String location, String type, String log) {
59 this(location, new Date(), type, log);
60 }
61
62 /** Creates a step of the given type. */
63 public ExecutionStep(String location, Date timestamp, String type,
64 String log) {
65 this(location, timestamp, type, log, Thread.currentThread().getName());
66 }
67
68 public ExecutionStep(String location, Date timestamp, String type,
69 String log, String thread) {
70 this.location = location;
71 this.type = type;
72 this.timestamp = timestamp;
73 this.thread = thread;
74 this.log = addLog(log);
75 }
76
77 public String getType() {
78 return type;
79 }
80
81 public Date getTimestamp() {
82 return timestamp;
83 }
84
85 public String getThread() {
86 return thread;
87 }
88
89 /**
90 * Return the string that should be stored in the log field. Can be null if
91 * another mechanism is used to store log lines.
92 */
93 protected String addLog(String log) {
94 return log;
95 }
96
97 public String getLog() {
98 return log;
99 }
100
101 @Override
102 public String toString() {
103 return "Execution step, thread=" + thread + ", type=" + type;
104 }
105
106 /** Typically the logging category */
107 public String getLocation() {
108 return location;
109 }
110
111 }