/* Copyright (C) 2013 Partnet, Inc.  Confidential and Proprietary. */
package com.foo;


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

import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;

/**
 * @author thart
 *
 */
public class GsonLoggingEventBuilder
{

  @SerializedName("message")
  private String message;

  @SerializedName("source_host")
  private String sourceHost;

  @SerializedName("fields")
  private Map<String, Object> fields = new HashMap<String, Object>();

  public void setMessage(String message)
  {
    this.message = message;
  }

  public void setSourceHost(String sourceHost)
  {
    this.sourceHost = sourceHost;
  }

  /**
   * @param fieldName
   * @param fieldValue
   */
  public void addField(String fieldName, Object fieldValue)
  {
    if (fieldName == null) {
      throw new IllegalArgumentException("fieldName is null");
    }
    fields.put(fieldName, fieldValue);
  }

  public String toJson()
  {
    return new Gson().toJson(this);
    //return new GsonBuilder().setPrettyPrinting().create().toJson(this);
  }
}
