     * First message always fails because database is not ready yet.
   """
   use GenEvent
-
-  alias Serverboards.Logger.Model
-  alias Serverboards.Repo
 
   @doc ~S"""
   Returns a list of mesages, it can receive a filter

defmodule Serverboards.Logger do
  @moduledoc ~S"""
  Stores log messages into the database.

  end

  def init(_opts) do
    {:ok, server} = Serverboards.Logger.Server.start_link name: Serverboards.Logger.Server
    {:ok, %{ ignore_applications: ignore_applications, queue: [], server: server }}
  end

  def handle_event(:flush, state) do
    Serverboards.Logger.Server.flush(state.server)
    {:ok, state}
  end
  # ignore if im not group leader
  def handle_event({_level, gl, {Logger, _, _, _}}, state)
      when node(gl) != node() do
    {:ok, state}
  end
  def handle_event({level, _group_leader, {Logger, message, timestamp, metadata}}, state) do
    if should_log?(metadata, level) do
      Serverboards.Logger.Server.log(state.server, {message, timestamp, metadata, level})
    end
    {:ok, state}
  end
  def handle_event({:configure, opts}, _state) do
    IO.puts("Logs configure: #{inspect opts}")
  end
end

defmodule Serverboards.Logger.Server do
  @moduledoc ~S"""
  Real logger to database; it has a queue and ensures data is properly saved
  without delaying the logger calls.
  """
  use GenServer

  @max_queue_size 10

  def start_link(options \\ []) do
    GenServer.start_link __MODULE__, [], options
  end
  def log(lg, msg) do
    GenServer.call(lg, {:log, msg})
    :ok
  end
  def flush(lg) do
    GenServer.call(lg, :flush)
    :ok
  end

  def to_json_type(v) do
