package de.ivu.elect.business.system.entity;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.exception.ExceptionUtils;

public class SkriptConsoleLog {

  private List<SkriptConsoleLogEntry> entries = new ArrayList<>();

  public void addInfoEntry(Object text) {
    entries.add(new SkriptConsoleLogEntry(LogSeverity.INFO, text));
  }

  public void addErrorEntry(Object text) {
    entries.add(new SkriptConsoleLogEntry(LogSeverity.ERROR, text));
  }

  public List<SkriptConsoleLogEntry> getEntries() {
    return entries;
  }

  public void addErrorEntry(Object msg, Throwable cause) {
    String stackTrace = ExceptionUtils.getStackTrace(cause);
    addErrorEntry(msg + "\n" + stackTrace);
  }

}
