package com.marinilli.b2.c7.deploylet;

/**
 * Chapter 7 - The DebugService runtime service
 *
 * @author Mauro Marinilli
 * @version 1.0
 */
public class DebugService implements DeploymentService, java.io.Serializable {
  private String message;
  private static StringBuffer log = new StringBuffer();
  private String tempLog;

  /**
   * default constructor
   */
  public DebugService() {
    this("");
  }

  /**
   * constructor
   */
  public DebugService(String msg) {
    message = msg;
    tempLog = log.toString();
  }

  /**
   * obtains in a standard way its data
   */
  public Object[] getContents() {
    String[] c = new String[2];
    c[0] = message;
    c[1] = tempLog;
    return c;
  }

  /**
   * records messages
   */
  public static void log(String s){
    log.append(s+"\n");
  }
}