Pudu programming language
Menu
Package

@chrismichaelps / pudu-lang-log

Structured event logging for Pudu: message templates, enrichment, filtering, formatting, and sinks

0.1.0Apache-2.01

InstallClose

Masking.pudu

Pudu26 lines1.2 KB

GitHub ↗
1/** @Example.Masking.Program — sensitive values hidden before any sink sees them */2module Masking34import Std.Io as Io5import PuduLangLog.Configuration as Configuration6import PuduLangLog.Enrichers.Masking as Masking7import PuduLangLog.Logger as Logger8import PuduLangLog.Sinks.Console as Console9import PuduLangLog.Value as Value1011/// Logs a sign-up with a password, an address, and a card number, all hidden, and answers 0.12fn main() -> Int {13  let patterns = match Masking.sensitive(Masking.MASK) {14    case Ok(enricher) => enricher15    case Err(problem) => {16      let _said = Io.writeErrorLine(problem)17      return 118    }19  }20  let logger = Configuration.create().enrichWith(Masking.properties(["Password", "Token"], Masking.MASK)).enrichWith(patterns).destructureByIgnoring("Account", ["Secret"]).writeTo(Console.sink(Console.Options{..Console.defaults(), colored: false})).createLogger()21  logger.information("Signed up \{Email\} with \{Password\}", [Value.text("ada@example.org"), Value.text("hunter2")])22  logger.information("Charged card \{Card\} for \{@Account\}", [Value.text("4111 1111 1111 1111"), Value.structure("Account", [("Name", Value.text("Ada")), ("Secret", Value.text("s3cret")), ("Token", Value.text("abc"))])])23  Logger.close(&logger)24  025}26