From f714438dd4439ddb96a56d4725734fd09dbd2e8b Mon Sep 17 00:00:00 2001 From: Bram Date: Mon, 3 Jun 2024 11:05:06 +0200 Subject: [PATCH] Add logs function for better runtime documentation --- src/Matrix.elm | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Matrix.elm b/src/Matrix.elm index 92d5876..379530b 100644 --- a/src/Matrix.elm +++ b/src/Matrix.elm @@ -1,6 +1,6 @@ module Matrix exposing ( Vault, fromUserId, fromUsername - , VaultUpdate, update + , VaultUpdate, update, logs , addAccessToken, sendMessageEvent ) @@ -24,7 +24,7 @@ support a monolithic public registry. (: ## Keeping the Vault up-to-date -@docs VaultUpdate, update +@docs VaultUpdate, update, logs ## Debugging @@ -112,6 +112,28 @@ fromUsername { username, host, port_ } = |> Vault +{-| The VaultUpdate is a complex type that helps update the Vault. However, +it also contains a human output! + +Using this function, you can get a human output that describes everything that +the VaultUpdate has to tell the Vault. + +The `channel` field describes the context of the log, allowing you to filter +further. For example: + + - `debug` is a comprehensive channel describing everything the Elm runtime has + executed. + - `warn` contains warnings that aren't breaking, but relevant. + - `securityWarn` warns about potential security issues or potential attacks. + - `error` has errors that were encountered. + - `caughtError` has errors that were dealt with successfully. + +-} +logs : VaultUpdate -> List { channel : String, content : String } +logs (VaultUpdate vu) = + vu.logs + + {-| Send a message event to a room. This function can be used in a scenario where the user does not want to sync