File.Only.Logger.Proxy (File-Only Logger v0.1.40) View Source
Implements logging messages to files only (not to the console).
Link to this section Summary
Functions
Returns the application for the current process or module.
Returns a formatted heredoc to trace a message from the given env
(Macro.Env
) and module
.
Returns string "<module>.<function>/<arity>" e.g. "My.Math.sqrt/1" from the
given env
(Macro.Env
).
Returns true
if value
is a positive integer, otherwise false
.
Returns the current library name.
Writes message
to the configured log file of logging level level
.
May prefix string
with "\n\s\s" if longer than limit
- offset
.
Returns the given module
as a string.
Link to this section Types
Specs
Message to be logged
Link to this section Functions
Specs
app() :: atom()
Returns the application for the current process or module.
Returns :undefined
if the current process does not belong to any
application or the current module is not listed in any application spec.
Examples
iex> alias File.Only.Logger.Proxy
iex> Proxy.app
:file_only_logger
Specs
from(Macro.Env.t()) :: String.t()
Returns a formatted heredoc to trace a message from the given env
(Macro.Env
).
Examples
iex> alias File.Only.Logger.Proxy
iex> heredoc = """
...> • App: file_only_logger
...> • Library: file_only_logger
...> • Function:\s
...> File.Only.Logger.ProxyTest.
...> """
...> |> String.trim_trailing()
iex> Proxy.from(__ENV__) =~ heredoc
true
Specs
from(Macro.Env.t(), module()) :: String.t()
Returns a formatted heredoc to trace a message from the given env
(Macro.Env
) and module
.
Examples
iex> alias File.Only.Logger.Proxy
iex> heredoc = """
...> • App: file_only_logger
...> • Library: file_only_logger
...> • Module: File.Only.Logger.ProxyTest
...> • Function:\s
...> File.Only.Logger.ProxyTest.
...> """
...> |> String.trim_trailing()
iex> Proxy.from(__ENV__, __MODULE__) =~ heredoc
true
Specs
fun(Macro.Env.t()) :: String.t()
Returns string "<module>.<function>/<arity>" e.g. "My.Math.sqrt/1" from the
given env
(Macro.Env
).
Examples
iex> defmodule My.Math do
...> alias File.Only.Logger.Proxy
...> def sqrt(_number) do
...> Proxy.fun(__ENV__)
...> end
...> end
iex> My.Math.sqrt(9)
"File.Only.Logger.ProxyTest.My.Math.sqrt/1"
Returns true
if value
is a positive integer, otherwise false
.
Specs
lib() :: atom()
Returns the current library name.
Examples
iex> alias File.Only.Logger.Proxy
iex> Proxy.lib
:file_only_logger
Specs
log(Logger.level(), message()) :: :ok
Writes message
to the configured log file of logging level level
.
Examples
iex> alias File.Only.Logger.Proxy
iex> Proxy.log(:debug, "*** String message ***")
:ok
iex> alias File.Only.Logger.Proxy
iex> Proxy.log(:debug, ['*** Improper', 'List' | 'Message ***'])
:ok
iex> alias File.Only.Logger.Proxy
iex> Proxy.log(:debug, fn -> "*** Function message ***" end)
:ok
iex> alias File.Only.Logger.Proxy
iex> Proxy.log(:debug, %{'first' => 'Map', 'last' => 'Message'})
:ok
iex> alias File.Only.Logger.Proxy
iex> Proxy.log(:debug, first: 'Keyword', last: 'Message')
:ok
Specs
maybe_break(String.t(), pos_integer(), pos_integer()) :: String.t()
May prefix string
with "\n\s\s" if longer than limit
- offset
.
Examples
iex> alias File.Only.Logger.Proxy
iex> supercal = "supercalifragilisticexpialidocious"
iex> heredoc = """
...> Feeling: #{supercal}
...> """
iex> Proxy.maybe_break(heredoc, 9)
"Feeling: supercalifragilisticexpialidocious\n"
iex> alias File.Only.Logger.Proxy
iex> supercal = "supercalifragilisticexpialidocious"
iex> heredoc = """
...> Feeling: #{supercal}ly #{supercal}
...> """
iex> Proxy.maybe_break(heredoc, 9) |> String.starts_with?("\n\s\sFeeling")
true
Specs
Returns the given module
as a string.
Examples
iex> alias File.Only.Logger.Proxy
iex> Proxy.mod(__MODULE__)
"File.Only.Logger.ProxyTest"
iex> alias File.Only.Logger.Proxy
iex> Proxy.mod(Elixir.Date.Range)
"Date.Range"