/** Copyright (c) MuteCode **/

export class SiloLog {
  /**
   * Short description of the log. E.g. 'timeout'
   */
  public shortDescription: string;

  /**
   * Detailed description of the log. E.g. 'Request timed out at ...'
   */
  public detailedDescription?: string = '';

  /**
   * Service name
   */
  public service?: string;

  /**
   * Severity level of the log (default is 1 which is an alert)
   */
  public level?: number = 1;

  /**
   * Which user triggered the log
   */
  public user?: string = '';
  
  /**
   * Which route the log is related to
   */
  public path?: string = '';

  /**
   * Status code of the log
   */
  public statusCode?: number = 0;

  /**
   * Timestamp of the log
   * Default is the current UTC time
   */
  public timestamp?: Date = new Date();

  constructor({
    service,
    shortDescription,
    detailedDescription,
    level,
    user,
    path,
    statusCode,
    timestamp,
  }: SiloLog) {
    this.service = service;
    this.shortDescription = shortDescription;
    if (detailedDescription) {
      this.detailedDescription = detailedDescription;
    }
    if (level) {
      this.level = level;
    }
    if (user) {
      this.user = user;
    }
    if (path) {
      this.path = path;
    }
    if (statusCode) {
      this.statusCode = statusCode;
    }
    if (timestamp) {
      this.timestamp = timestamp;
    }
  }
}
