tricycle / system-actor-model / System.Log

The System and your Actors can LogMessage through this module.

The System itself doesn't store these log messages anywhere, It's up to you to handle and/or store these messages through an Actor.


type alias LogMessage addresses actors appMsg =
System.Internal.Message.LogMessage addresses actors appMsg

The opaque LogMessage type

You can create LogMessages using the helper function available

Create

emergency : System.Internal.PID.PID -> String -> LogMessage addresses actors appMsg

Create a new LogMessage with the severity Emergency

alert : System.Internal.PID.PID -> String -> LogMessage addresses actors appMsg

Create a new LogMessage with the severity Alert

critical : System.Internal.PID.PID -> String -> LogMessage addresses actors appMsg

Create a new LogMessage with the severity Critical

error : System.Internal.PID.PID -> String -> LogMessage addresses actors appMsg

Create a new LogMessage with the severity Error

warning : System.Internal.PID.PID -> String -> LogMessage addresses actors appMsg

Create a new LogMessage with the severity Warning

notice : System.Internal.PID.PID -> String -> LogMessage addresses actors appMsg

Create a new LogMessage with the severity Notice

info : System.Internal.PID.PID -> String -> LogMessage addresses actors appMsg

Create a new LogMessage with the severity Informational

debug : System.Internal.PID.PID -> String -> LogMessage addresses actors appMsg

Create a new LogMessage with the severity Debug

Time

When you create a log message through any of the create helpers your log message will not have a time accociated with it.

withPosix : LogMessage addresses actors appMsg -> Time.Posix -> LogMessage addresses actors appMsg

Add a Posix (elm/time) to your LogMessage

Msg

What was the message that resulted in this LogMessage? I don't know, but if you supply it I'll store it on the LogMessage type!

withMessage : System.Message.SystemMessage addresses actors appMsg -> LogMessage addresses actors appMsg -> LogMessage addresses actors appMsg

Supply a Message that resulted in this logMessage

You could use this to retry a failed command for instance.

Helpers

toString : LogMessage addresses actors appMsg -> String

Turn a LogMessage into a String

error pid appMsg "I'm sorry Dave, I'm afraid I can't do that"
    |> toString

-- error | 2(1) | I'm sorry Dave, I'm afraid I can't do that

error system appMsg "I'm sorry Dave, I'm afraid I can't do that"
    |> withPosix now
    |> toString

-- 2019/12/25 12:59:59 (UTC) | error | system | I'm sorry Dave, I'm afraid I can't do that

severityToString : Severity -> String

Severity to String

toMeta : LogMessage addresses actors appMsg -> { posix : Maybe Time.Posix, severity : Severity, pid : System.Internal.PID.PID, message : Maybe (System.Message.SystemMessage addresses actors appMsg), description : String }

LogMessage to Description