<?php

namespace App\Libraries\Log;

class Log
{
  private static $_logs = array();
  private static $_dbInstance = null;
  public function __construct()
  {
  }
  final static public function add(string $level, string $content)
  {
    $content = date("H:i:s") . "-[{$level}]:{$content}";
    if ($level !== "debug") {
      array_push(self::$_logs, $content);
    }
    log_message($level, $content);
  }
  final static public function save(string $title, bool $status = true)
  {
    if (self::$_dbInstance === null) {
      self::$_dbInstance = new \App\Libraries\Log\DataBase();
    }
    self::$_dbInstance->save($title, $status, self::$_logs);
    self::$_logs = array();
  }
}
