View Javadoc

1   package org.csc.phynixx.watchdog.log;
2   
3   /*
4    * #%L
5    * phynixx-watchdog
6    * %%
7    * Copyright (C) 2014 csc
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  
23  
24  import org.csc.phynixx.watchdog.IWatchedCondition;
25  
26  /**
27   *
28   * Created by christoph on 09.06.2012.
29   */
30  public class CheckConditionFailedLog implements IWatchdogLog {
31  
32      private long timestamp = 0l;
33      private String condition = null;
34      private String description = null;
35  
36      public CheckConditionFailedLog(IWatchedCondition condition) {
37          super();
38          this.timestamp = System.currentTimeMillis();
39          this.condition = condition.toString();
40  
41          this.description = condition != null ? condition.toString() : "?";
42      }
43  
44      public CheckConditionFailedLog(IWatchedCondition condition, String description) {
45          super();
46          if( condition==null) {
47              throw new IllegalArgumentException("Condition must be defined");
48          }
49          this.timestamp = System.currentTimeMillis();
50          this.condition = condition.toString();
51          this.description = this.condition + " " + description;
52  
53      }
54  
55      public long getTimestamp() {
56          return timestamp;
57      }
58  
59      public String getCondition() {
60          return condition;
61      }
62  
63      public String getDescription() {
64          return this.description;
65      }
66  
67      public String toString() {
68          return "CheckConditionFailed : " + this.getDescription();
69      }
70  
71  
72  }