blob: fabf8a3e4fc2a0944b15a32842d19c54e17cff35 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.brooklyn.util.core.logbook;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.brooklyn.util.exceptions.Exceptions;
import java.util.Date;
/**
* This class models the log format used by Apache Brooklyn by default
* @see `etc/org.ops4j.pax.logging.cfg`
*/
public class BrooklynLogEntry {
String lineId;
@JsonProperty("timestamp")
String timestampString;
Date datetime;
String taskId;
String entityIds;
String level;
String bundleId;
@JsonProperty("class")
String clazz;
String threadName;
String message;
public String getLineId() {
return lineId;
}
public void setLineId(String lineId) {
this.lineId = lineId;
}
public String getTimestampString() {
return timestampString;
}
public void setTimestampString(String timestampString) {
this.timestampString = timestampString;
}
public Date getDatetime() {
return datetime;
}
public void setDatetime(Date datetime) {
this.datetime = datetime;
}
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getEntityIds() {
return entityIds;
}
public void setEntityIds(String entityIds) {
this.entityIds = entityIds;
}
public String getLevel() {
return level;
}
public void setLevel(String level) {
this.level = level;
}
public String getBundleId() {
return bundleId;
}
public void setBundleId(String bundleId) {
this.bundleId = bundleId;
}
public String getClazz() {
return clazz;
}
public void setClazz(String clazz) {
this.clazz = clazz;
}
public String getThreadName() {
return threadName;
}
public void setThreadName(String threadName) {
this.threadName = threadName;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String toJsonString() {
String json = "";
try {
ObjectMapper objectMapper = new ObjectMapper();
json = objectMapper.writeValueAsString(this);
} catch (JsonProcessingException e) {
Exceptions.propagate(e);
}
return json;
}
@Override
public String toString() {
return "{" +
"timestamp='" + timestampString + '\'' +
", taskId='" + taskId + '\'' +
", entityIds='" + entityIds + '\'' +
", level='" + level + '\'' +
", bundle_id='" + bundleId + '\'' +
", clazz='" + clazz + '\'' +
", thread_name='" + threadName + '\'' +
", message='" + message + '\'' +
'}';
}
}