From f978fcccaa56f7f73ffd619a8aced81443342ddc Mon Sep 17 00:00:00 2001 From: Jon Pretty Date: Tue, 7 Nov 2023 06:09:18 +0100 Subject: [PATCH] Provided a `LogFormat` for `Syslog` --- src/core/logging.scala | 1 + src/syslog/syslog.scala | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/core/logging.scala b/src/core/logging.scala index 888d3ba..4177cd0 100644 --- a/src/core/logging.scala +++ b/src/core/logging.scala @@ -38,6 +38,7 @@ case class Realm private(name: Text): object Level: given Ordering[Level] = Ordering[Int].on[Level](_.ordinal) given Communicable[Level] = level => Message(level.show.upper) + given Show[Level] = _.toString.tt.upper enum Level: case Fine, Info, Warn, Fail diff --git a/src/syslog/syslog.scala b/src/syslog/syslog.scala index 0d86475..5a3c74b 100644 --- a/src/syslog/syslog.scala +++ b/src/syslog/syslog.scala @@ -20,12 +20,15 @@ import guillotine.* import rudiments.* import parasite.* import anticipation.* +import gossamer.* import turbulence.* import perforate.* case class Syslog(tag: Text) object Syslog: + given LogFormat[Syslog] = entry => + t"[${entry.level}] ${entry.realm}: ${entry.message}\n" given (using Monitor): Appendable[Syslog, Text] = (syslog, stream) => safely: