summaryrefslogtreecommitdiff
path: root/lib/exirc/logger.ex
blob: 65ae98018cf3bd1c2dd2c21ad8b87d540f6d2a2e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
defmodule ExIrc.Logger do
  @moduledoc """
  A simple abstraction of :error_logger
  """

  @doc """
  Log an informational message report
  """
  @spec info(binary) :: :ok
  def info(msg) do
    :error_logger.info_report String.to_charlist(msg)
  end

  @doc """
  Log a warning message report
  """
  @spec warning(binary) :: :ok
  def warning(msg) do
    :error_logger.warning_report String.to_charlist("#{IO.ANSI.yellow()}#{msg}#{IO.ANSI.reset()}")
  end

  @doc """
  Log an error message report
  """
  @spec error(binary) :: :ok
  def error(msg) do
    :error_logger.error_report String.to_charlist("#{IO.ANSI.red()}#{msg}#{IO.ANSI.reset()}")
  end
end