1/** @Log.Event.Access — building, reading, and changing events */2modulePuduLangLog.Event34importPuduLangLog.Constants.NamesasNames5importPuduLangLog.Domain.DisplayasDisplay6importPuduLangLog.Domain.ParserasParser7importPuduLangLog.Domain.PropertiesasProperties8importPuduLangLogasLog910/// An event from its parts, with no failure, trace, or span.11exportfncreate(timestamp: Log.Timestamp, level: Log.Level, template: Str, properties: Array[Log.Property]) -> Log.Event {12Log.Event{timestamp: timestamp, level: level, template: Parser.parse(template), properties: properties, failure: None, traceId: None, spanId: None}13}1415/// The message: the template rendered with the event's properties.16exportfnmessage(event: &Log.Event) -> Str { Display.plain(&Display.message(&event.template, &event.properties, &None)) }1718/// The value of a property.19exportfnproperty(event: &Log.Event, name: Str) -> Option[Log.Value] { Properties.find(&event.properties, name) }2021/// The source context, when the event carries one as text.22exportfnsourceContext(event: &Log.Event) -> Option[Str] {23match property(event, Names.SOURCE_CONTEXT) {24caseSome(Log.Scalar(Log.Text(source))) => Some(source)25case _ => None26 }27}2829/// The event with a property set, replacing any value it had.30exportfnwithProperty(event: &Log.Event, name: Str, held: Log.Value) -> Log.Event {31Log.Event{..*event, properties: Properties.put(&event.properties, name, held)}32}3334/// The event with a property set unless it already has one of that name.35exportfnwithPropertyIfAbsent(event: &Log.Event, name: Str, held: Log.Value) -> Log.Event {36Log.Event{..*event, properties: Properties.putIfAbsent(&event.properties, name, held)}37}3839/// The event without a property.40exportfnwithoutProperty(event: &Log.Event, name: Str) -> Log.Event {41Log.Event{..*event, properties: Properties.remove(&event.properties, name)}42}4344/// The event with a failure attached.45exportfnwithFailure(event: &Log.Event, problem: Log.Failure) -> Log.Event { Log.Event{..*event, failure: Some(problem)} }4647/// The event with a trace and span identifier.48exportfnwithTrace(event: &Log.Event, traceId: Str, spanId: Str) -> Log.Event {49Log.Event{..*event, traceId: Some(traceId), spanId: Some(spanId)}50}51