Skip to content
/ toprox Public

A simple proxy for different Logger backends which allows to filter messages based on metadata.

License

Notifications You must be signed in to change notification settings

diyzx/toprox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Toprox

Build Status Hex version License

A simple proxy for different Logger backends which allows to filter messages based on metadata.

Installation

Add toprox to your list of dependencies in mix.exs:

def deps do
  [
    {:toprox, "~> 0.1"}
  ]
end

Configuration

Config would have an entry similar to this:

config :logger, backends: [
  {Toprox, :graylog},
  {Toprox, :rotate_log},
  {Toprox, :warn_console},
  :console
]
  
config :logger, :graylog,
  level: :info,
  backend: {
    Logger.Backends.Gelf, [
      host: "graylog.example.com",
      port: 12201,
      application: "MyApplication",
      compression: :gzip,
      metadata: [:request_id, :function, :module, :file, :line]
    ]
  }

config :logger, :rotate_log,
  level: :info,
  backend: {
    Loggix, [
      path: "test.log",
      json_encoder: Poison,
      rotate: %{max_bytes: 1024, keep: 5},
      metadata: [:user_id, :request_id]
    ]
  }

config :logger, :warn_console,
  level: :warn,
  backend: {
    Toprox.Console, [
      format: ">>> $date $time [$level] $metadata$message\n",
      metadata: [:user_id]
    ]
  }

config :logger, :console,
  format: "$date [$level] $metadata$message\n",
  metadata: [:request_id]

If you want to use toprox for standard Console backend you should use Toprox.Console instead like in the sample above.

Usage

Use :topic in Logger metadata to write message to appropriate log:

Logger.info "Info", topic: :graylog
Logger.error "Error", topic: [:rotate_log, :warn_console]

About

A simple proxy for different Logger backends which allows to filter messages based on metadata.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages