Equations
- Lake.instReprVerbosity = { reprPrec := Lake.reprVerbosity✝ }
Equations
- Lake.instDecidableEqVerbosity x y = if h : x.toCtorIdx = y.toCtorIdx then isTrue ⋯ else isFalse ⋯
Equations
- Lake.instOrdVerbosity = { compare := Lake.ordVerbosity✝ }
Equations
- Lake.instInhabitedVerbosity = { default := Lake.Verbosity.normal }
Whether to ANSI escape codes.
- auto: Lake.AnsiMode
Automatically determine whether to use ANSI escape codes based on whether the stream written to is a terminal.
- ansi: Lake.AnsiMode
Use ANSI escape codes.
- noAnsi: Lake.AnsiMode
Do not use ANSI escape codes.
Returns whether to ANSI escape codes with the stream out
.
Equations
Wrap text in ANSI escape sequences to make it bold and color it the ANSI colorCode
.
Resets all terminal font attributes at the end of the text.
A pure representation of output stream.
- stdout: Lake.OutStream
- stderr: Lake.OutStream
- stream: IO.FS.Stream → Lake.OutStream
Returns the real output stream associated with OutStream
.
Equations
- Lake.OutStream.stdout.get = IO.getStdout
- Lake.OutStream.stderr.get = IO.getStderr
- (Lake.OutStream.stream s).get = pure s
Equations
- Lake.instCoeStreamOutStream = { coe := Lake.OutStream.stream }
Equations
- Lake.instCoeHandleOutStream = { coe := fun (h : IO.FS.Handle) => Lake.OutStream.stream (IO.FS.Stream.ofHandle h) }
- trace: Lake.LogLevel
- info: Lake.LogLevel
- warning: Lake.LogLevel
- error: Lake.LogLevel
Equations
- Lake.instInhabitedLogLevel = { default := Lake.LogLevel.trace }
Equations
- Lake.instReprLogLevel = { reprPrec := Lake.reprLogLevel✝ }
Equations
- Lake.instDecidableEqLogLevel x y = if h : x.toCtorIdx = y.toCtorIdx then isTrue ⋯ else isFalse ⋯
Equations
- Lake.instOrdLogLevel = { compare := Lake.ordLogLevel✝ }
Equations
- Lake.instToJsonLogLevel = { toJson := Lake.toJsonLogLevel✝ }
Equations
- Lake.instFromJsonLogLevel = { fromJson? := Lake.fromJsonLogLevel✝ }
Unicode icon for representing the log level.
Equations
- Lake.LogLevel.trace.icon = 'ℹ'
- Lake.LogLevel.info.icon = 'ℹ'
- Lake.LogLevel.warning.icon = '⚠'
- Lake.LogLevel.error.icon = '✖'
ANSI escape code for coloring text of at the log level.
Equations
- Lake.LogLevel.trace.ansiColor = "34"
- Lake.LogLevel.info.ansiColor = "34"
- Lake.LogLevel.warning.ansiColor = "33"
- Lake.LogLevel.error.ansiColor = "31"
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lake.LogLevel.trace.toString = "trace"
- Lake.LogLevel.info.toString = "info"
- Lake.LogLevel.warning.toString = "warning"
- Lake.LogLevel.error.toString = "error"
Equations
- Lake.instToStringLogLevel = { toString := Lake.LogLevel.toString }
Equations
- Lake.LogLevel.info.toMessageSeverity = Lean.MessageSeverity.information
- Lake.LogLevel.trace.toMessageSeverity = Lean.MessageSeverity.information
- Lake.LogLevel.warning.toMessageSeverity = Lean.MessageSeverity.warning
- Lake.LogLevel.error.toMessageSeverity = Lean.MessageSeverity.error
Equations
- Lake.Verbosity.quiet.minLogLv = Lake.LogLevel.warning
- Lake.Verbosity.normal.minLogLv = Lake.LogLevel.info
- Lake.Verbosity.verbose.minLogLv = Lake.LogLevel.trace
- level : Lake.LogLevel
- message : String
Equations
- Lake.instInhabitedLogEntry = { default := { level := default, message := default } }
Equations
- Lake.instToJsonLogEntry = { toJson := Lake.toJsonLogEntry✝ }
Equations
- Lake.instFromJsonLogEntry = { fromJson? := Lake.fromJsonLogEntry✝ }
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lake.instToStringLogEntry = { toString := fun (self : Lake.LogEntry) => self.toString }
Equations
- Lake.logVerbose message = Lake.logEntry { level := Lake.LogLevel.trace, message := message }
Equations
- Lake.logInfo message = Lake.logEntry { level := Lake.LogLevel.info, message := message }
Equations
- Lake.logWarning message = Lake.logEntry { level := Lake.LogLevel.warning, message := message }
Equations
- Lake.logError message = Lake.logEntry { level := Lake.LogLevel.error, message := message }
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lake.logToStream e out minLv useAnsi = if e.level ≥ minLv then EIO.catchExceptions (out.putStrLn (e.toString useAnsi)) fun (x : IO.Error) => pure () else pure PUnit.unit
Equations
- Lake.MonadLog.nop = { logEntry := fun (x : Lake.LogEntry) => pure () }
Equations
- Lake.MonadLog.instInhabitedOfPure = { default := Lake.MonadLog.nop }
Equations
- self.lift = { logEntry := fun (e : Lake.LogEntry) => liftM (Lake.logEntry e) }
Equations
- Lake.MonadLog.instOfMonadLift = methods.lift
Equations
- Lake.MonadLog.io minLv = { logEntry := fun (e : Lake.LogEntry) => liftM (Lake.logToIO e minLv) }
Equations
- Lake.MonadLog.stream out minLv useAnsi = { logEntry := fun (e : Lake.LogEntry) => liftM (Lake.logToStream e out minLv useAnsi) }
Equations
- self.logEntry e minLv ansiMode = do let out ← self.get let useAnsi ← Lake.AnsiMode.isEnabled out ansiMode Lake.logToStream e out minLv useAnsi
Equations
- out.logger minLv ansiMode = { logEntry := fun (e : Lake.LogEntry) => liftM (out.logEntry e minLv ansiMode) }
Equations
- Lake.MonadLog.stdout minLv ansiMode = Lake.OutStream.stdout.logger minLv ansiMode
Equations
- Lake.MonadLog.stderr minLv ansiMode = Lake.OutStream.stderr.logger minLv ansiMode
Equations
- out.getLogger minLv ansiMode = do let out ← out.get let useAnsi ← Lake.AnsiMode.isEnabled out ansiMode pure (Lake.MonadLog.stream out minLv useAnsi)
A monad equipped with a MonadLog
instance
Equations
- Lake.MonadLogT m n = ReaderT (Lake.MonadLog m) n
Equations
- Lake.MonadLogT.instInhabitedOfPure = { default := fun (x : Lake.MonadLog m) => pure default }
Equations
- Lake.MonadLogT.instMonadLogOfMonadOfMonadLiftT = { logEntry := fun (e : Lake.LogEntry) => do let __do_lift ← read liftM (Lake.logEntry e) }
Equations
- Lake.MonadLogT.adaptMethods f self = ReaderT.adapt f self
Equations
- self.ignoreLog = self Lake.MonadLog.nop
Equations
- Lake.instToJsonLog = { toJson := fun (x : Lake.Log) => Lean.toJson x.entries }
Equations
- Lake.instFromJsonLog = { fromJson? := fun (x : Lean.Json) => Lake.Log.mk <$> Lean.fromJson? x }
Equations
- Lake.Log.instInhabitedPos = { default := { val := default } }
Equations
- Lake.instOfNatPos = { ofNat := { val := 0 } }
Equations
- Lake.Log.instEmptyCollection = { emptyCollection := Lake.Log.empty }
Equations
- log.endPos = { val := log.entries.size }
Equations
- log.push e = { entries := log.entries.push e }
Equations
- Lake.Log.instAppend = { append := Lake.Log.append }
Takes log entries between start
(inclusive) and stop
(exclusive).
Equations
- log.extract start stop = { entries := log.entries.extract start.val stop.val }
Removes log entries after pos
(inclusive).
Equations
- log.dropFrom pos = { entries := log.entries.shrink pos.val }
Takes log entries before pos
(exclusive).
Equations
- log.takeFrom pos = log.extract pos log.endPos
Splits the log into two from pos
.
The first log is from the start to pos
(exclusive),
and the second log is from pos
(inclusive) to the end.
Equations
- log.split pos = (log.dropFrom pos, log.takeFrom pos)
Equations
- log.toString = Array.foldl (fun (x1 : String) (x2 : Lake.LogEntry) => x1 ++ x2.toString ++ "\n") "" log.entries
Equations
- Lake.Log.instToString = { toString := Lake.Log.toString }
Equations
- log.replay = Array.forM (fun (e : Lake.LogEntry) => Lake.logEntry e) log.entries
Equations
- Lake.Log.filter f log = { entries := Array.filter f log.entries }
Equations
- Lake.Log.any f log = log.entries.any f
The max log level of entries in this log. If empty, returns trace
.
Equations
- log.maxLv = Array.foldl (fun (x1 : Lake.LogLevel) (x2 : Lake.LogEntry) => max x1 x2.level) Lake.LogLevel.trace log.entries
Equations
- Lake.MonadLog.ofMonadState = { logEntry := Lake.pushLogEntry }
Returns the current end position of the monad's log (i.e., its size).
Removes the monad's log starting at pos
and returns it.
Useful for extracting logged errors after catching an error position
from an ELogT
(e.g., LogIO
).
Equations
- Lake.takeLogFrom pos = modifyGet fun (log : Lake.Log) => (log.takeFrom pos, log.dropFrom pos)
Returns the log from x
while leaving it intact in the monad.
Equations
- Lake.extractLog x = do let iniPos ← Lake.getLogPos x let log ← Lake.getLog pure (log.takeFrom iniPos)
Returns the log from x
and its result while leaving it intact in the monad.
Equations
- Lake.withExtractLog x = do let iniPos ← Lake.getLogPos let a ← x let log ← Lake.getLog pure (a, log.takeFrom iniPos)
Performs x
and backtracks any error to the log position before x
.
Equations
- Lake.withLogErrorPos self = do let iniPos ← Lake.getLogPos tryCatch self fun (x : Lake.Log.Pos) => throw iniPos
Performs x
and groups all logs generated into an error block.
Equations
- Lake.errorWithLog self = do let iniPos ← Lake.getLogPos tryCatch self fun (x : Lake.Log.Pos) => pure () throw iniPos
Captures IO in x
into an informational log entry.
Equations
- One or more equations did not get rendered due to their size.
Throw with the logged error message
.
Equations
- Lake.ELog.error msg = Lake.errorWithLog (Lake.logError msg)
Alternative
instance for monads with Log
state and Log.Pos
errors.
Fail without logging anything.
Performs x
. If it fails, drop its log and perform y
.
Equations
- Lake.ELog.orElse x y = tryCatch x fun (errPos : Lake.Log.Pos) => do Lake.dropLogFrom errPos y ()
Alternative
instance for monads with Log
state and Log.Pos
errors.
Equations
- Lake.ELog.alternative = Alternative.mk (fun {α : Type} => Lake.ELog.failure) fun {α : Type} => Lake.ELog.orElse
Equations
- Lake.instMonadLogLogTOfMonad = Lake.MonadLog.ofMonadState
Run self
with the log taken from the state of the monad n
.
Warning: If lifting self
from m
to n
fails, the log will be lost.
Thus, this is best used when the lift cannot fail.
Runs self
in n
and then replays the entries of the resulting log
using the new monad's logger
.
A monad equipped with a log and the ability to error at some log position.
Equations
Equations
Equations
- Lake.instMonadLogELogTOfMonad = Lake.MonadLog.ofMonadState
Equations
- Lake.instMonadErrorELogTOfMonad = Lake.ELog.monadError
Equations
- Lake.instAlternativeELogTOfMonad = Lake.ELog.alternative
Equations
- self.run log = Lake.EStateT.run log self
Equations
- self.run' log = Lake.EStateT.run' log self
Equations
- self.toLogT = Lake.EStateT.toStateT self
Equations
- self.toLogT? = Lake.EStateT.toStateT? self
Equations
- self.run? log = Lake.EStateT.run? log self
Equations
- self.run?' log = Lake.EStateT.run?' log self
Equations
- Lake.ELogT.catchLog f self = Lake.EStateT.catchExceptions self fun (errPos : Lake.Log.Pos) => do let __do_lift ← Lake.takeLogFrom errPos f __do_lift
Equations
Run self
with the log taken from the state of the monad n
,
Warning: If lifting self
from m
to n
fails, the log will be lost.
Thus, this is best used when the lift cannot fail. Note excludes the
native log position failure of ELogT
, which are lifted safely.
Equations
- One or more equations did not get rendered due to their size.
Runs self
in n
and then replays the entries of the resulting log
using the new monad's logger
. Translates an exception in this monad
to a none
result.
Equations
- One or more equations did not get rendered due to their size.
Runs self
in n
and then replays the entries of the resulting log
using the new monad's logger
. Translates an exception in this monad to
a failure
in the new monad.
Equations
- One or more equations did not get rendered due to their size.
A monad equipped with a log, a log error position, and the ability to perform I/O.
Equations
Equations
- Lake.instMonadLiftIOLogIO = { monadLift := fun {α : Type} => Lake.MonadError.runIO }
Equations
Runs a LogIO
action in BaseIO
.
Prints log entries of at least minLv
to out
.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lake.LogIO.toBaseIO.replay log logger = log.replay