bunyan_shared v0.1.0 Bunyan.Shared.Readable
This module creates the basic environment for a Bunyan source plugin, reasponsible for capturing loggable events and injecting them into the collector.
To create new reader plugin:
mix new bunyan_source_«name» --module Bunyan.Source.«Name»
Decide what configuration options your plugin needs. Create a module
Bunyan.Source.«Name».State
that defines a structure to hold the options. That structure must also contain a field namedcollector
, which this module will populate with a reference to the collector your code should send messages to.Also in that module write a function
@spec from(keyword) :: %__MODULE__{}
This is responsible for taking a set of options from the runtime configuration of the app that uses your plugin and using them to populate the structure. You’ll also do validation here, raising exceptions for bad or missing options.
Delete
lib/bunyan_source_«name».ex
.Create
lib/«name».ex
:
defmodule Bunyan.Source.«Name» do
use Bunyan.Shared.Readable
def start(config) do
# your code goes here
end
end
Your start
function will be passed the structure you populated in step 2.
It can send messages to the config.collector
to inject them into the main
logger.
Link to this section Summary
Functions
If called in Bunyan.Source.Api, this generates
Link to this section Types
Link to this section Functions
If called in Bunyan.Source.Api, this generates
def child_spec({ collector, config }) do
Supervisor.child_spec({ Bunyan.Source.Api.Server, state }, [])
end
def state_from_config(collector, config) do
Readable.validate_collector(Bunyan.Source.Api, collector)
Bunyan.Source.Api.State.from(config) |> Map.put(:collector, collector)
end