loggix v0.0.6 Loggix

Loggix

A custom implementation for Elixir Logger module.

  • Using GenEvent for handle log events.

Configration

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,
json_encoder: Poison # configure json encoder, which has the function `encode!/2`, which 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.

JSON Encoding

if json_encoder will specified in configration. json_encoder.encode!/1 will executed. Ex. json_encoder: Poison Poison.encode!(%{level: “”, message: “”, time : “”})… if json_encoder option is not existed in config/config.exs, formatting style will follow ‘format’ configration.

Log Rotation

Logrotate configration 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.init/1

Callback implementation for c::gen_event.terminate/2

Link to this section Types

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 json_encoder()
json_encoder() :: Module.t
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.

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

Link to this function terminate(reason, state)

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