ensoft / entrance / EnTrance.Feature.Target.Syslog

Listen for syslogs. Minimal example:

import EnTrance.Channel as Channel
import EnTrance.Feature.Router.Syslog as Syslog
import EnTrance.Types exposing (MaybeSubscribe(..))

Syslog.start IgnoreConState [] []
    |> Channel.send model

Target.connect params
    |> Channel.send model

Once the connection is up, you will received a notification of type "syslog", that can be decoded using decode into a Syslog type.

Adding debug and/or filters

If you want to turn on one or more debugs, you can do that:

debugs = ["debug sysdb access", "debug sysdb verification"]

Syslog.start IgnoreConState debugs []
    |> Channel.send model

If you want to filter syslogs, you can provide a list of matching strings (in fact Python regular expressions). If this is non-empty, then only syslogs matching at least one filter will be sent.

-- Just tell me about commits
filters = ["%MGBL-CONFIG-6-DB_COMMIT"]

Syslog.start IgnoreConState [] filters
    |> Channel.send model

And you can combine both debugs and filters:

debugs = ["debug sysdb access", "debug sysdb verification"]
filters = ["sysdb"]

Syslog.start IgnoreConState debug filters
    |> Channel.send model

start : EnTrance.Types.MaybeSubscribe -> List String -> List String -> EnTrance.Request.Request

Start listening for syslogs on a single target. This is an async request - use the connection state notifications to track progress.

stop : EnTrance.Request.Request

Stop listening for syslogs.


type Syslog
    = Syslog String Basics.Float

A received syslog: a message and a timestamp.

decode : (Syslog -> msg) -> Json.Decode.Decoder msg

Decode a syslog notification into a Syslog. Takes a message constructor.

decodeIsUp : (Basics.Bool -> msg) -> Json.Decode.Decoder msg

Decode an up/down notification requested by passing SubscribeToConState to start. Takes a message constructor.