/*
 * Copyright 2012-2014 TORCH GmbH
 *
 * This file is part of Graylog2.
 *
 * Graylog2 is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Graylog2 is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Graylog2.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.graylog2.gelfclient;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Bernd Ahlers <bernd@torch.sh>
 */
public class GelfMessage {
    private final GelfMessageVersion version;

    public GelfMessage(GelfMessageVersion version) {
        this.version = version;
    }

    public GelfMessageVersion getVersion() {
        return version;
    }

    public double getTimestamp() {
        return (System.currentTimeMillis() / 1000D);
    }

    public String getMessage() {
        return "This is the short_message.";
    }

    public String getHost() {
        return "localhost";
    }

    public Map<String, Object> getAdditionalFields() {
        Map<String, Object> fields = new HashMap<>();

        fields.put("_foo", "bar");

        return fields;
    }

    public String toString() {
        return String.format("[GelfMessage] version=%s short_message=%s", getVersion().toString(), getMessage());
    }
}

@@ -913,16 +913,52 @@
 version;
+%0A    private final double timestamp;
 %0A%0A    pu
@@ -1028,32 +1028,93 @@
 sion = version;%0A
+        this.timestamp = System.currentTimeMillis() / 1000D;%0A
     %7D%0A%0A    publi
@@ -1234,44 +1234,17 @@
 urn 
-(System.currentTimeMillis() / 1000D)
+timestamp
 ;%0A  

Build timestamp value on object creation.