loggix v0.0.9 Loggix

Loggix

A custom implementation for Elixir Logger module.

  • Using GenEvent for handle log events.

configuration

Tell Logger Loggix as backend config/config.ex.

config :logger,
  backends: [{Loggix, :dev_log}, {Loggix, :json_log}]
config :logger, :dev_log,
  format: "[$level] $metadata $message [$time]", # configure format
  metadata: [:uuid, :is_auth], # configure metadatas
  rotate: %{max_bytes: 4096, size: 4} # configure log rotation. max_bytes: max byte size of 1 file, size : max count of rotate log file.
config :logger, :json_log,
encoder: {Poison, :encode!} # a tuple `{module, function_atom}` which accepts a [`Map`](https://hexdocs.pm/elixir/Map.html) and returns iodata.

Format

Default formatting style is below:

@log_default_format "$time $metadata [$level] $message
"

You can configure a custom formatting style format : "..." in config/config.exs.

Custom Encoding

if encoder will specified in configuration, its function will executed. Ex. encoder: {Poison, :encode!} Poison.encode!(%{level: “”, message: “”, time : “”})… if encoder option does not exists in config/config.exs, formatting style will follow ‘format’ configuration.

Log Rotation

Logrotate configuration which like erlang.log can be customized.

  • size

    • it will specify a log generation size, default is 5.
  • max_bytes

    • it will specify max byte of one log.

Example

For Example, if you specify max_bytes is 1024, size is 4.

  • 0
`new data` : 2 byte => dev.log : 1024 byte
  • 1
dev_log =(rename)=> dev_log.1

then touch dev_log : 0 byte
  • 2
`new data : 2 byte` => dev_log : 0 byte
dev_log.1 : 1024 byte
  • 3
dev_log : 2 byte
dev_log.1 : 1024 byte

Link to this section Summary

Functions

Callback implementation for c::gen_event.code_change/3

Callback implementation for c::gen_event.handle_call/2

Callback implementation for c::gen_event.handle_event/2

Callback implementation for c::gen_event.handle_info/2

Callback implementation for c::gen_event.init/1

Callback implementation for c::gen_event.terminate/2

Link to this section Types

Link to this type encoder()
encoder() :: {Module.t(), :atom}
Link to this type file()
file() :: :file.io_device()
Link to this type format()
format() :: String.t()
Link to this type inode()
inode() :: File.Stat.t()
Link to this type level()
level() :: Logger.level()
Link to this type metadata()
metadata() :: [atom()]
Link to this type path()
path() :: String.t()

Link to this section Functions

Link to this function code_change(old, state, extra)

Callback implementation for c::gen_event.code_change/3.

Link to this function handle_call(arg1, state)

Callback implementation for c::gen_event.handle_call/2.

Link to this function handle_event(arg1, state)

Callback implementation for c::gen_event.handle_event/2.

Link to this function handle_info(message, state)

Callback implementation for c::gen_event.handle_info/2.

Callback implementation for c::gen_event.init/1.

Link to this function terminate(reason, state)

Callback implementation for c::gen_event.terminate/2.