logger
logger-color
1 Basic Loggers
trce
dbug
info
warn
erro
crit
ftal
2 No-expression Loggers
trce*
dbug*
info*
warn*
erro*
crit*
ftal*
3 No-expression +   Time/  Source Loggers
trce^
dbug^
info^
warn^
erro^
crit^
ftal^
4 Fully Verbose Loggers
trce+
dbug+
info+
warn+
erro+
crit+
ftal+
5 Examples
7.0

logger

Kevin Robert Stravers

 (require logger) package: logger

Provides simple colored logging functionality of various log levels.

procedure

(logger-color state)  void?

  state : (or/c 'automatic #t #f)
Sets the logger color.

1 Basic Loggers

syntax

(trce expr ...)

Prints the expression in its code-form as well as the result of evaluating the expression.

Examples:
> (logger-color #f)
> (trce (+ 1 2))

(trce (+ 1 2) = 3)

3

A logger can be suffixed by a symbol. What follows is a list of applicable symbols:
  • No suffix prints the expression as well as its result

  • * suffix prints the result, and _ instead of the expression. Can only handle one argument

  • ^ suffix is similar to * but also prints the date and source location

  • + prints the date, source location, expression, and result. It is the most verbose suffix.

All loggers return their last input.

Besides trce, the following loggers are implemented: dbug info warn erro crit ftal. Accompanying suffixes apply.

syntax

(dbug expr ...)

syntax

(info expr ...)

syntax

(warn expr ...)

syntax

(erro expr ...)

syntax

(crit expr ...)

syntax

(ftal expr ...)

Forms of the default logger. Prints both syntax and the result of an evaluation. Logs a separate line for each expression.

2 No-expression Loggers

syntax

(trce* expr)

syntax

(dbug* expr)

syntax

(info* expr)

syntax

(warn* expr)

syntax

(erro* expr)

syntax

(crit* expr)

syntax

(ftal* expr)

Forms of the succinct logger. Prints only the result of an evaluation. Logs a separate line for each expression.

3 No-expression + Time/Source Loggers

syntax

(trce^ expr)

syntax

(dbug^ expr)

syntax

(info^ expr)

syntax

(warn^ expr)

syntax

(erro^ expr)

syntax

(crit^ expr)

syntax

(ftal^ expr)

Forms of the source-succinct logger. Prints the time, source file, line, and the result of an evaluation.

4 Fully Verbose Loggers

syntax

(trce+ expr ...)

syntax

(dbug+ expr ...)

syntax

(info+ expr ...)

syntax

(warn+ expr ...)

syntax

(erro+ expr ...)

syntax

(crit+ expr ...)

syntax

(ftal+ expr ...)

Forms of the source-verbose logger. Prints the time, source file, line, expression, and the result of an evaluation.

5 Examples

Here are some examples of the loggers.

Examples:
> (dbug  (+ 1 (sqr 2)))

(dbug (+ 1 (sqr 2)) = 5)

5

> (trce* (+ 1 2))

(trce* _ = 3)

3

> (crit^ (number->string (+ 1 2)))

(crit^ 2018-08-18T06:46:00 (unknown 5 0) _ = "3")

"3"

> (info+ `(connection-established ,8000))

(info+

 2018-08-18T06:46:00

 (unknown 6 0)

 `(connection-established ,8000)

 =

 (connection-established 8000))

'(connection-established 8000)