The log4cl-extras Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The log4cl-extras Reference Manual

This is the log4cl-extras Reference Manual, version 0.5.1, generated automatically by Declt version 3.0 "Montgomery Scott" on Wed Oct 13 11:43:32 2021 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

LOG4CL-EXTRAS - Addons for Log4CL

Table of Contents

[in package LOG4CL-EXTRAS/DOC]

1 LOG4CL-EXTRAS ASDF System Details

2 Installation

This library is not available from Quicklisp yet, but you can install it from Ultralisp.org:

(ql-dist:install-dist "http://dist.ultralisp.org/"
                      :prompt nil)
(ql:quickload :log4cl-extras)

3 Configuration

[in package LOG4CL-EXTRAS/CONFIG]

By default LOG4CL outputs log items like this:

CL-USER> (log:info "Hello")
 <INFO> [01:15:37] cl-user () - Hello

However logging extra context fields requires a custom "layout". Layout defines the way how the message will be formatted.

This system defines two layout types:

To use these custom layouts, you have to use SETUP function. It also allows to set a log level for root logger and appenders. Here is a minimal example showing how to configure logger for the REPL:

CL-USER> (log4cl-extras/config:setup
          '(:level :debug
            :appenders ((this-console :layout :plain))))
NIL

CL-USER> (log:info "Hello")
<INFO> [2021-05-16T01:16:46.978992+03:00] Hello

CL-USER> (log4cl-extras/context:with-fields (:foo "Bar")
           (log:info "Hello"))
<INFO> [2021-05-16T01:26:30.331849+03:00] Hello
  Fields:
    foo: Bar

If you replace :PLAIN with :JSON, you'll get this:

CL-USER> (log4cl-extras/config:setup
          '(:level :debug
            :appenders ((this-console :layout :json))))
; No values
CL-USER> (log4cl-extras/context:with-fields (:foo "Bar")
           (log:info "Hello"))
{"fields":{"foo":"Bar"},"level":"INFO","message":"Hello","timestamp":"2021-05-16T01:27:54.879336+03:00"}

Appender in terms of log4cl is a target for log output. You can combine multiple appenders in a single call to SETUP function.

Here is the example of the config, suitable for production. Here we log all messages as JSON records into the file, rotated on the daily basis. And all errors and warnings will be written to the REPL.

(log4cl-extras/config:setup
 '(:level :debug
   :appenders ((this-console :layout :plain
                             :filter :warn)
               (daily :layout :json
                      :name-format "/app/logs/app.log"
                      :backup-name-format "app-%Y%m%d.log"))))

Also, SETUP allows to change log levels for different loggers:

4 Context Fields

[in package LOG4CL-EXTRAS/CONTEXT]

Macro WITH-FIELDS let to to capture some information into the dynamic variable. All messages logged inside the WITH-FIELDS form will have these fields attached:

CL-USER> (log4cl-extras/config:setup
          '(:level :debug
            :appenders ((this-console :layout :plain))))

CL-USER> (defun process-request ()
           (log:info "Processing request"))

CL-USER> (log4cl-extras/context:with-fields (:request-id 42)
           (process-request))
<INFO> [2020-07-19T10:03:21.079636Z] Processing request
  Fields:
    request-id: 42

;; Now let's switch to JSON layout:
CL-USER> (log4cl-extras/config:setup
          '(:level :debug
            :appenders ((this-console :layout :json))))

CL-USER> (log4cl-extras/context:with-fields (:request-id 42)
           (process-request))
{"fields": {"request-id": 42},
 "level": "INFO",
 "message": "Processing request",
 "timestamp": "2020-07-19T10:03:32.855593Z"}

Beware!, catching context fields costs some time even if they are not logged.

5 Logging Unhandled Errors

[in package LOG4CL-EXTRAS/ERROR]

5.1 Quickstart

If you want to log unhandled signals traceback, then use WITH-LOG-UNHANDLED macro.

Usually it is good idea, to use WITH-LOG-UNHANDLED in the main function or in a function which handles a HTTP request.

If some error condition will be signaled by the body, it will be logged as an error with "traceback" field like this:

CL-USER> (defun foo ()
           (error "Some error happened"))

CL-USER> (defun bar ()
           (foo))

CL-USER> (log4cl-extras/error:with-log-unhandled ()
           (bar))

<ERROR> [2020-07-19T10:14:39.644805Z] Unhandled exception
  Fields:
  Traceback (most recent call last):
    File "NIL", line NIL, in FOO
      (FOO)
    File "NIL", line NIL, in BAR
      (BAR)
    File "NIL", line NIL, in (LAMBDA (…
      ((LAMBDA ()))
    File "NIL", line NIL, in SIMPLE-EV…
      (`SB-INT:SIMPLE-EVAL-IN-LEXENV`
       (`LOG4CL-EXTRAS/ERROR:WITH-LOG-UNHANDLED` NIL
         (BAR))
       #<NULL-LEXENV>)
    ...
       #<CLOSURE (LAMBDA () :IN `SLYNK::CALL-WITH-LISTENER`) {100A6B043B}>)
     
     
  Condition: Some error happened
; Debugger entered on #<SIMPLE-ERROR "Some error happened" {100A7A5DB3}>

The JSON layout will write such error like this:

{
  "fields": {
    "traceback": "Traceback (most recent call last):\n  File \"NIL\", line NIL, in FOO\n    (FOO)\n  File \"NIL\", line NIL, in BAR\n    (BAR)\n...\nCondition: Some error happened"
  },
  "level": "ERROR",
  "message": "Unhandled exception",
  "timestamp": "2020-07-19T10:21:33.557418Z"
}

5.2 Printing Backtrace

There is a helper function PRINT-BACKTRACE for extracting and printing backtrace, which can be used separately from logging. One use case is to render backtrace on the web page when a site is in a debug mode:

CL-USER> (log4cl-extras/error:print-backtrace :depth 3)
Traceback (most recent call last):
   0 File "/Users/art/.roswell/src/sbcl-2.0.11/src/code/eval.lisp", line 291
       In `SB-INT:SIMPLE-EVAL-IN-LEXENV`
     Args ((`LOG4CL-EXTRAS/ERROR:PRINT-BACKTRACE` :DEPTH 3) #<NULL-LEXENV>)
   1 File "/Users/art/.roswell/src/sbcl-2.0.11/src/code/eval.lisp", line 311
       In EVAL
     Args ((`LOG4CL-EXTRAS/ERROR:PRINT-BACKTRACE` :DEPTH 3))
   2 File "/Users/art/projects/lisp/sly/contrib/slynk-mrepl.lisp"
       In (LAMBDA () :IN `SLYNK-MREPL::MREPL-EVAL-1`)
     Args ()

By default, it prints to the *DEBUG-IO*, but you can pass it a :STREAM argument which has the same semantic as a stream for FORMAT function.

Other useful parameters are :DEPTH and :MAX-CALL-LENGTH. They allow to control how long and wide backtrace will be.

Also, you might pass :CONDITION. If it is given, it will be printed after the backtrace.

And finally, you can pass a list of functions to filter arguments before printing. This way secret or unnecesary long values can be stripped. See the next section to learn how to not log secret values.

6 How Keep Secrets Out of Logs

[in package LOG4CL-EXTRAS/SECRETS]

When backtrace is printed to log files it is good idea to omit passwords, tokens, cookies, and other potentially sensitive values.

Here is a potential situation where you have a password and trying to create a new connection to the database. But because of some network error, an unhandled error along with a backtrace will be logged. Pay attention to our secret password in the log:

CL-USER> (log4cl-extras/config:setup
           '(:level :error
             :appenders ((this-console :layout plain))))
   
CL-USER> (defun connect (password)
           "Normally, we don't control this function's code
  because it is from the third-party library."
           (check-type password string)
           (error "Network timeout"))
   
CL-USER> (defun authenticate (password)
           "This function is in our app's codebase.
  It is calling a third-party DB driver."     
           (connect password))
   
CL-USER> (defun bar (password)
           (authenticate password))
   
CL-USER> (log4cl-extras/error:with-log-unhandled (:depth 5)
           (bar "The Secret Password"))
<ERROR> [2021-01-24T14:13:24.460890+03:00] Unhandled exception
  Fields:
  Traceback (most recent call last):
     0 File "unknown"
         In (FLET "H0")
       Args (#<SIMPLE-ERROR "Network timeout" {100F065533}>)
     1 File "/Users/art/.roswell/src/sbcl-2.0.11/src/code/cold-error.lisp", line 81
         In SB-KERNEL::%SIGNAL
       Args (#<SIMPLE-ERROR "Network timeout" {100F065533}>)
     2 File "/Users/art/.roswell/src/sbcl-2.0.11/src/code/cold-error.lisp", line 154
         In ERROR
       Args ("Network timeout")
     3 File "unknown"
         In CONNECT
       Args ("The Secret Password")
     4 File "unknown"
         In AUTHENTICATE
       Args ("The Secret Password")
  
  Condition: Network timeout

With LOG4CL-EXTRAS you can keep values in secret in two ways.

6.1 Easy Way

The easiest way, is two wrap all sensitive data using secret-values library as soon as possible and unwrap them only before usage.

Lets see what will happen if we'll use a wrapped password.

First, we need to teach AUTHENTICATE function, how to unwrap the password, before passing it to the driver:

CL-USER> (defun authenticate (password)
           "This function is in our app's codebase.
  It is calling a third-party DB driver."
           (connect
            (secret-values:ensure-value-revealed
             password)))

Next, we need to wrap password into a special object. It is better to do this as soon as possible. In production code you'll probably have something like (secret-values:conceal-value (uiop:getenv "POSTGRES_PASSWORD")):

CL-USER> (log4cl-extras/error:with-log-unhandled (:depth 5)
           (bar (secret-values:conceal-value
                 "The Secret Password")))
<ERROR> [2021-01-24T14:16:01.667651+03:00] Unhandled exception
  Fields:
  Traceback (most recent call last):
     0 File "unknown"
         In (FLET "H0")
       Args (#<SIMPLE-ERROR "Network timeout" {10036CB1A3}>)
     1 File "/Users/art/.roswell/src/sbcl-2.0.11/src/code/cold-error.lisp", line 81
         In SB-KERNEL::%SIGNAL
       Args (#<SIMPLE-ERROR "Network timeout" {10036CB1A3}>)
     2 File "/Users/art/.roswell/src/sbcl-2.0.11/src/code/cold-error.lisp", line 154
         In ERROR
       Args ("Network timeout")
     3 File "unknown"
         In CONNECT
       Args ("The Secret Password")
     4 File "unknown"
         In AUTHENTICATE
       Args (#<SECRET-VALUES:SECRET-VALUE {10036CB183}>)
     
  Condition: Network timeout

Pay attention to the fourth stack frame. AUTHENTICATE function has #<SECRET-VALUES:SECRET-VALUE {10036CB183}> as the first argument. But why do we see "The Secret Password" in the third frame anyway?

It is because we have to pass a raw version of the password to the libraries we don't control.

Here is where LOG4CL-EXTRAS comes to the resque. It provides a subsystem LOG4CL-EXTRAS/SECRETS. It is optional and is not loaded together with the primary system.

Earlier, I've mentioned :ARGS-FILTERS argument to the LOG4CL-EXTRAS/ERROR:PRINT-BACKTRACE function. Package LOG4CL-EXTRAS/SECRETS provides a function MAKE-SECRETS-REPLACER which can be used to filter secret values.

We can add it into the global variable LOG4CL-EXTRAS/ERROR:*ARGS-FILTERS* like this:

CL-USER> (ql:quickload :log4cl-extras/secrets)
(:LOG4CL-EXTRAS/SECRETS)
   
CL-USER> (setf log4cl-extras/error:*args-filters*
               (list (log4cl-extras/secrets:make-secrets-replacer)))
(#<CLOSURE (LABELS `LOG4CL-EXTRAS/SECRETS::REMOVE-SECRETS` :IN `LOG4CL-EXTRAS/SECRETS:MAKE-SECRETS-REPLACER`) {1007E4464B}>)

Now let's try to connect to our fake database again:

CL-USER> (log4cl-extras/error:with-log-unhandled (:depth 5)
           (bar (secret-values:conceal-value
                 "The Secret Password")))
<ERROR> [2021-01-24T14:27:17.851716+03:00] Unhandled exception
  Fields:
  Traceback (most recent call last):
     0 File "unknown"
         In (FLET "H0")
       Args (#<SIMPLE-ERROR "Network timeout" {100800F723}>)
     1 File "/Users/art/.roswell/src/sbcl-2.0.11/src/code/cold-error.lisp", line 81
         In SB-KERNEL::%SIGNAL
       Args (#<SIMPLE-ERROR "Network timeout" {100800F723}>)
     2 File "/Users/art/.roswell/src/sbcl-2.0.11/src/code/cold-error.lisp", line 154
         In ERROR
       Args ("Network timeout")
     3 File "unknown"
         In CONNECT
       Args (#<secret value>)
     4 File "unknown"
         In AUTHENTICATE
       Args (#<secret value>)
  
  Condition: Network timeout

Now both third and fourth frames show #<secret value> instead of the password. This is because (log4cl-extras/secrets:make-secrets-replacer) call returns a closure which remembers and replaces raw values of the secrets too!

6.2 Hard Way

Sometimes it is desireable to remove from tracebacks other kinds of data. For example I don't want to see Lack's environments, because of a few reasons:

Let's create a filter for arguments, which will replace Lack's environments with a placeholder.

First, we need to create a placeholder object:

CL-USER> (defvar +lack-env-placeholder+
           (log4cl-extras/error:make-placeholder "lack env"))
+LACK-ENV-PLACEHOLDER+

Next, we need to define a filter function. Each filter function should accept two arguments:

Filter should return two values, which can be the same is inputs or a transformed in some way.

For example, we know that the Lack's env is a plist with :REQUEST-METHOD, :REQUEST-URI and other values. We can to write a predicate like this:

CL-USER> (defun lack-env-p (arg)
           (and (listp arg)
                (member :request-method arg)
                (member :request-uri arg)))

And to use it in our filter:

CL-USER> (defun remove-lack-env-from-frame (func-name args)
           "Removes Lack's env from stackframes to make backtrace concise."
           (values func-name
                   (loop for arg in args
                         if (lack-env-p arg)
                           collect +lack-env-placeholder+
                         else
                           collect arg)))

Now let's try to use it:

CL-USER> (defun request-handler (app env)
           (authenticate (secret-values:conceal-value
                          "Secret password"))
           (pass-further app env))
   
CL-USER> (setf log4cl-extras/error:*args-filters*
               (list 'remove-lack-env-from-frame
                     ;; We need this too to keep DB password safe, remember?
                     (log4cl-extras/secrets:make-secrets-replacer)))

Now pay attention to the fifth frame, where second argument is replaced with #<lack env>!!!

CL-USER> (log4cl-extras/error:with-log-unhandled (:depth 7)
           (request-handler 42
                            (list :request-method :post
                                  :request-uri "/login/"
                                  :cookies "Session hash, and other secrets.")))
<ERROR> [2021-01-24T14:56:45.502656+03:00] Unhandled exception
  Fields:
  Traceback (most recent call last):
     0 File "unknown"
         In (FLET "H0")
       Args (#<SIMPLE-ERROR "Network timeout" {1004233EB3}>)
     1 File "/Users/art/.roswell/src/sbcl-2.0.11/src/code/cold-error.lisp", line 81
         In SB-KERNEL::%SIGNAL
       Args (#<SIMPLE-ERROR "Network timeout" {1004233EB3}>)
     2 File "/Users/art/.roswell/src/sbcl-2.0.11/src/code/cold-error.lisp", line 154
         In ERROR
       Args ("Network timeout")
     3 File "unknown"
         In CONNECT
       Args (#<secret value>)
     4 File "unknown"
         In AUTHENTICATE
       Args (#<secret value>)
     5 File "unknown"
         In REQUEST-HANDLER
       Args (42 #<lack env>)
     6 File "unknown"
         In (LAMBDA ())
       Args ()
     
  Condition: Network timeout

For such simple case like replacing args matching a predicate, LOG4CL-EXTRAS has a small helper LOG4CL-EXTRAS/ERROR:MAKE-ARGS-FILTER:

CL-USER> (setf log4cl-extras/error:*args-filters*
               (list (log4cl-extras/error:make-args-filter
                      'lack-env-p
                      (log4cl-extras/error:make-placeholder "LACK ENV BEING HERE"))
                     ;; We need this too to keep DB password safe, remember?
                     (log4cl-extras/secrets:make-secrets-replacer)))
   
<ERROR> [2021-01-24T15:09:48.839513+03:00] Unhandled exception
  Fields:
  Traceback (most recent call last):
     0 File "unknown"
         In (FLET "H0")
       Args (#<SIMPLE-ERROR "Network timeout" {1003112243}>)
     1 File "/Users/art/.roswell/src/sbcl-2.0.11/src/code/cold-error.lisp", line 81
         In SB-KERNEL::%SIGNAL
       Args (#<SIMPLE-ERROR "Network timeout" {1003112243}>)
     2 File "/Users/art/.roswell/src/sbcl-2.0.11/src/code/cold-error.lisp", line 154
         In ERROR
       Args ("Network timeout")
     3 File "unknown"
         In CONNECT
       Args (#<secret value>)
     4 File "unknown"
         In AUTHENTICATE
       Args (#<secret value>)
     5 File "unknown"
         In REQUEST-HANDLER
       Args (42 #<LACK ENV BEING HERE>)
     6 File "unknown"
         In (LAMBDA ())
       Args ()
  
  Condition: Network timeout


[generated by [40ANTS-DOC](https://40ants.com/doc

Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Next: , Previous: , Up: Systems   [Contents][Index]

2.1 log4cl-extras

Author

Alexander Artemenko

Home Page

https://40ants.com/log4cl-extras

Source Control

(:git "https://github.com/40ants/log4cl-extras")

Bug Tracker

https://github.com/40ants/log4cl-extras/issues

License

BSD

Description

A bunch of addons to LOG4CL: JSON appender, context fields, cross-finger appender, etc.

Long Description

This library extends LOG4CL system in a few ways:

* It helps with configuration of multiple appenders and layouts.
* Has a facility to catch context fields and to log them.
* Has a macro to log unhandled errors.
* Adds a layout to write messages as JSON, which is useful for production as makes easier to parse and process such logs. * Uses the appenders which are not disabled in case of some error which again, should be useful for production.

Version

0.5.1

Dependencies
Source

log4cl-extras.asd (file)


Next: , Previous: , Up: Systems   [Contents][Index]

2.2 log4cl-extras/config

Author

Alexander Artemenko

Home Page

https://40ants.com/log4cl-extras

Source Control

(:git "https://github.com/40ants/log4cl-extras")

Bug Tracker

https://github.com/40ants/log4cl-extras/issues

License

BSD

Dependencies
Source

log4cl-extras.asd (file)

Component

file-type.lisp (file)


Next: , Previous: , Up: Systems   [Contents][Index]

2.3 log4cl-extras/json

Author

Alexander Artemenko

Home Page

https://40ants.com/log4cl-extras

Source Control

(:git "https://github.com/40ants/log4cl-extras")

Bug Tracker

https://github.com/40ants/log4cl-extras/issues

License

BSD

Dependencies
Source

log4cl-extras.asd (file)

Component

file-type.lisp (file)


Next: , Previous: , Up: Systems   [Contents][Index]

2.4 log4cl-extras/plain

Author

Alexander Artemenko

Home Page

https://40ants.com/log4cl-extras

Source Control

(:git "https://github.com/40ants/log4cl-extras")

Bug Tracker

https://github.com/40ants/log4cl-extras/issues

License

BSD

Dependencies
Source

log4cl-extras.asd (file)

Component

file-type.lisp (file)


Next: , Previous: , Up: Systems   [Contents][Index]

2.5 log4cl-extras/appenders

Author

Alexander Artemenko

Home Page

https://40ants.com/log4cl-extras

Source Control

(:git "https://github.com/40ants/log4cl-extras")

Bug Tracker

https://github.com/40ants/log4cl-extras/issues

License

BSD

Dependency

log4cl

Source

log4cl-extras.asd (file)

Component

file-type.lisp (file)


Next: , Previous: , Up: Systems   [Contents][Index]

2.6 log4cl-extras/error

Author

Alexander Artemenko

Home Page

https://40ants.com/log4cl-extras

Source Control

(:git "https://github.com/40ants/log4cl-extras")

Bug Tracker

https://github.com/40ants/log4cl-extras/issues

License

BSD

Dependencies
Source

log4cl-extras.asd (file)

Component

file-type.lisp (file)


Next: , Previous: , Up: Systems   [Contents][Index]

2.7 log4cl-extras/context

Author

Alexander Artemenko

Home Page

https://40ants.com/log4cl-extras

Source Control

(:git "https://github.com/40ants/log4cl-extras")

Bug Tracker

https://github.com/40ants/log4cl-extras/issues

License

BSD

Dependencies
Source

log4cl-extras.asd (file)

Component

file-type.lisp (file)


Previous: , Up: Systems   [Contents][Index]

2.8 log4cl-extras/utils

Author

Alexander Artemenko

Home Page

https://40ants.com/log4cl-extras

Source Control

(:git "https://github.com/40ants/log4cl-extras")

Bug Tracker

https://github.com/40ants/log4cl-extras/issues

License

BSD

Dependencies
Source

log4cl-extras.asd (file)

Component

file-type.lisp (file)


Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 log4cl-extras.asd

Location

/home/quickref/quicklisp/dists/quicklisp/software/log4cl-extras-20210531-git/log4cl-extras.asd

Systems

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.2 log4cl-extras/config/file-type.lisp

Parent

log4cl-extras/config (system)

Location

config.lisp

Packages

log4cl-extras/config

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.3 log4cl-extras/json/file-type.lisp

Parent

log4cl-extras/json (system)

Location

json.lisp

Packages

log4cl-extras/json

Exported Definitions

json-layout (class)

Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.4 log4cl-extras/plain/file-type.lisp

Parent

log4cl-extras/plain (system)

Location

plain.lisp

Packages

log4cl-extras/plain

Exported Definitions

plain-layout (class)

Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.5 log4cl-extras/appenders/file-type.lisp

Parent

log4cl-extras/appenders (system)

Location

appenders.lisp

Packages

log4cl-extras/appenders

Exported Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.6 log4cl-extras/error/file-type.lisp

Parent

log4cl-extras/error (system)

Location

error.lisp

Packages

log4cl-extras/error

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.7 log4cl-extras/context/file-type.lisp

Parent

log4cl-extras/context (system)

Location

context.lisp

Packages

log4cl-extras/context

Exported Definitions
Internal Definitions

*fields* (special variable)


Previous: , Up: Lisp files   [Contents][Index]

3.1.8 log4cl-extras/utils/file-type.lisp

Parent

log4cl-extras/utils (system)

Location

utils.lisp

Packages

log4cl-extras/utils

Exported Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

4.1 log4cl-extras/config

Source

file-type.lisp (file)

Use List

common-lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Packages   [Contents][Index]

4.2 log4cl-extras/json

Source

file-type.lisp (file)

Use List

common-lisp

Exported Definitions

json-layout (class)

Internal Definitions

Next: , Previous: , Up: Packages   [Contents][Index]

4.3 log4cl-extras/plain

Source

file-type.lisp (file)

Use List

common-lisp

Exported Definitions

plain-layout (class)

Internal Definitions

Next: , Previous: , Up: Packages   [Contents][Index]

4.4 log4cl-extras/appenders

Source

file-type.lisp (file)

Use List

common-lisp

Exported Definitions

Next: , Previous: , Up: Packages   [Contents][Index]

4.5 log4cl-extras/error

Source

file-type.lisp (file)

Use List

common-lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Packages   [Contents][Index]

4.6 log4cl-extras/context

Source

file-type.lisp (file)

Use List

common-lisp

Exported Definitions
Internal Definitions

*fields* (special variable)


Previous: , Up: Packages   [Contents][Index]

4.7 log4cl-extras/utils

Source

file-type.lisp (file)

Use List

common-lisp

Exported Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Special variables

Special Variable: @configuration
Package

log4cl-extras/config

Source

file-type.lisp (file)

Special Variable: @context
Package

log4cl-extras/context

Source

file-type.lisp (file)

Special Variable: @errors
Package

log4cl-extras/error

Source

file-type.lisp (file)

Special Variable: @intro
Package

log4cl-extras/error

Source

file-type.lisp (file)

Special Variable: @printing
Package

log4cl-extras/error

Source

file-type.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Macros

Macro: with-fields (&rest FIELDS) &body BODY

Captures content of given fields into a dynamic variable.

These fields will be logged along with any log entry inside the WITH-FIELDS body.

Package

log4cl-extras/context

Source

file-type.lisp (file)

Macro: with-log-unhandled (&key DEPTH) &body BODY

Logs any ERROR condition signaled from the body. Logged message will have a "traceback" field.

Package

log4cl-extras/error

Source

file-type.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.3 Functions

Function: get-fields ()

Returns an alist of all fields defined using WITH-FIELDS macro in the current stack.

Keys are returned as downcased strings, prepared for logging.

Package

log4cl-extras/context

Source

file-type.lisp (file)

Function: get-timestamp &key TIMEZONE
Package

log4cl-extras/utils

Source

file-type.lisp (file)

Function: is-sly-stream STREAM
Package

log4cl-extras/utils

Source

file-type.lisp (file)

Function: limit-length TEXT MAX-LEN
Package

log4cl-extras/utils

Source

file-type.lisp (file)

Function: make-args-filter PREDICATE PLACEHOLDER

Returns a function, suitable to be used in *ARGS-FILTERS*

Function PREDICATE will be applied to each argument in the frame and if it returns T, then argument will be replaced with PLACEHOLDER.

Package

log4cl-extras/error

Source

file-type.lisp (file)

Function: make-placeholder NAME

Creates a placeholder for some secret value or omitted argument.

“‘
CL-USER> (log4cl-extras/error:make-placeholder "secret value")

#<secret value>
“‘

Package

log4cl-extras/error

Source

file-type.lisp (file)

Function: placeholder-p OBJ
Package

log4cl-extras/error

Source

file-type.lisp (file)

Function: print-backtrace &key STREAM CONDITION DEPTH MAX-CALL-LENGTH ARGS-FILTERS

A helper to print backtrace. Could be useful to out backtrace
at places other than logs, for example at a web page.

This function applies the same filtering rules as WITH-LOG-UNHANDLED macro.

Package

log4cl-extras/error

Source

file-type.lisp (file)

Function: print-with-indent STREAM PREFIX TEXT

Prints a prefix to each line of the of the text.

Package

log4cl-extras/utils

Source

file-type.lisp (file)

Function: remove-newlines TEXT
Package

log4cl-extras/utils

Source

file-type.lisp (file)

Function: setup CONFIG

Setup loggers and appenders via confg.

Example:

“‘
(setup
’(:level :error
:appenders
(this-console
(file
:file "foo.log"
:layout json))
:loggers
((log4cl-extras/config
:loggers
((foo :level :debug)
(bar
:loggers
((some-class
:level debug))))))))
“‘

As you can see, SETUP function accepts a plist with keys :LEVEL, :APPENDERS and :LOGGERS.

:LEVEL key holds a logging level for the root logger. It could be :INFO, :WARN or :ERROR.

:APPENDERS is a list of list where each sublist should start from the appender type and arguments for it’s constructor.

Supported appenders are:

* ‘THIS-CONSOLE‘ corresponds to LOG4CL:THIS-CONSOLE-APPENDER class.
* ‘DAILY‘ corresponds to LOG4CL:DAILY-FILE-APPENDER class.
* ‘FILE‘ corresponds to LOG4CL:FILE-APPENDER.

To lookup supported arguments for each appender type, see these classes initargs.
the only difference is that :LAYOUT argument is processed in a special way:
:JSON value replaced with LOG4CL-EXTRAS/JSON:JSON-LAYOUT and :PLAIN is replaced
with LOG4CL-EXTRAS/PLAIN:PLAIN-LAYOUT.

And finally, you can pass to SETUP a list of loggers. Each item in this list
should be plist where first item is a symbolic name of a package or a function name
inside a package and other items are params for a nested SETUP call.

Package

log4cl-extras/config

Source

file-type.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.4 Generic functions

Generic Function: placeholder-name OBJECT
Package

log4cl-extras/error

Methods
Method: placeholder-name (PLACEHOLDER placeholder)

automatically generated reader method

Source

file-type.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

5.1.5 Classes

Class: dont-disable-mixin ()
Package

log4cl-extras/appenders

Source

file-type.lisp (file)

Direct superclasses

standard-object (class)

Direct subclasses
Direct methods

handle-appender-error (method)

Class: json-layout ()
Package

log4cl-extras/json

Source

file-type.lisp (file)

Direct superclasses

layout (class)

Direct methods
Direct slots
Slot: timezone
Type

local-time::timezone

Initargs

:timezone

Initform

local-time:*default-timezone*

Readers

get-timezone (generic function)

Class: plain-layout ()
Package

log4cl-extras/plain

Source

file-type.lisp (file)

Direct superclasses

layout (class)

Direct methods
Direct slots
Slot: timezone
Type

local-time::timezone

Initargs

:timezone

Initform

local-time:*default-timezone*

Readers

get-timezone (generic function)

Class: stable-daily-file-appender ()
Package

log4cl-extras/appenders

Source

file-type.lisp (file)

Direct superclasses
Class: stable-file-appender ()
Package

log4cl-extras/appenders

Source

file-type.lisp (file)

Direct superclasses
Class: stable-this-console-appender ()
Package

log4cl-extras/appenders

Source

file-type.lisp (file)

Direct superclasses

Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Special variables

Special Variable: *d*
Package

log4cl-extras/error

Source

file-type.lisp (file)

Special Variable: *fields*

A stack of data fields to be serialized to JSON

Fields are stored as a plist, and transformed into an alist before serialization.

Package

log4cl-extras/context

Source

file-type.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Functions

Function: apply-args-filters FUNC-NAME ARGS &key ARGS-FILTERS
Package

log4cl-extras/error

Source

file-type.lisp (file)

Function: format-frame STREAM IDX CALL ARGS FILE LINE &key MAX-CALL-LENGTH
Package

log4cl-extras/error

Source

file-type.lisp (file)

Function: from-current-package FRAME
Package

log4cl-extras/error

Source

file-type.lisp (file)

Function: get-backtrace ()
Package

log4cl-extras/error

Source

file-type.lisp (file)

Function: make-appender NAME ARGS
Package

log4cl-extras/config

Source

file-type.lisp (file)

Function: make-layout NAME ARGS
Package

log4cl-extras/config

Source

file-type.lisp (file)

Function: make-logger CATEGORIES
Package

log4cl-extras/config

Source

file-type.lisp (file)

Function: prepare FRAME ARGS-FILTERS
Package

log4cl-extras/error

Source

file-type.lisp (file)

Function: setup-logger LOGGER &key APPENDERS LOGGERS LEVEL
Package

log4cl-extras/config

Source

file-type.lisp (file)

Function: write-json-item STREAM LOG-FUNC LEVEL &key TIMEZONE
Package

log4cl-extras/json

Source

file-type.lisp (file)

Function: write-plain-item STREAM LOG-FUNC LEVEL &key TIMEZONE
Package

log4cl-extras/plain

Source

file-type.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.3 Generic functions

Generic Function: get-timezone OBJECT
Package

log4cl-extras/json

Methods
Method: get-timezone (JSON-LAYOUT json-layout)

automatically generated reader method

Source

file-type.lisp (file)

Generic Function: get-timezone OBJECT
Package

log4cl-extras/plain

Methods
Method: get-timezone (PLAIN-LAYOUT plain-layout)

automatically generated reader method

Source

file-type.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.4 Classes

Class: placeholder ()

Objects of this class can be used as replacement to arguments in a backtrace.

They are printed like ‘#<some-name>‘.

This form was choosen to match the way how SBCL shows unused arguments: ‘#<unused argument>‘.

Placeholders should be created with MAKE-PLACEHOLDER function.

Package

log4cl-extras/error

Source

file-type.lisp (file)

Direct superclasses

standard-object (class)

Direct methods
Direct slots
Slot: name
Type

string

Initargs

:name

Readers

placeholder-name (generic function)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   L  
Index Entry  Section

F
File, Lisp, log4cl-extras.asd: The log4cl-extras․asd file
File, Lisp, log4cl-extras/appenders/file-type.lisp: The log4cl-extras/appenders/file-type․lisp file
File, Lisp, log4cl-extras/config/file-type.lisp: The log4cl-extras/config/file-type․lisp file
File, Lisp, log4cl-extras/context/file-type.lisp: The log4cl-extras/context/file-type․lisp file
File, Lisp, log4cl-extras/error/file-type.lisp: The log4cl-extras/error/file-type․lisp file
File, Lisp, log4cl-extras/json/file-type.lisp: The log4cl-extras/json/file-type․lisp file
File, Lisp, log4cl-extras/plain/file-type.lisp: The log4cl-extras/plain/file-type․lisp file
File, Lisp, log4cl-extras/utils/file-type.lisp: The log4cl-extras/utils/file-type․lisp file

L
Lisp File, log4cl-extras.asd: The log4cl-extras․asd file
Lisp File, log4cl-extras/appenders/file-type.lisp: The log4cl-extras/appenders/file-type․lisp file
Lisp File, log4cl-extras/config/file-type.lisp: The log4cl-extras/config/file-type․lisp file
Lisp File, log4cl-extras/context/file-type.lisp: The log4cl-extras/context/file-type․lisp file
Lisp File, log4cl-extras/error/file-type.lisp: The log4cl-extras/error/file-type․lisp file
Lisp File, log4cl-extras/json/file-type.lisp: The log4cl-extras/json/file-type․lisp file
Lisp File, log4cl-extras/plain/file-type.lisp: The log4cl-extras/plain/file-type․lisp file
Lisp File, log4cl-extras/utils/file-type.lisp: The log4cl-extras/utils/file-type․lisp file
log4cl-extras.asd: The log4cl-extras․asd file
log4cl-extras/appenders/file-type.lisp: The log4cl-extras/appenders/file-type․lisp file
log4cl-extras/config/file-type.lisp: The log4cl-extras/config/file-type․lisp file
log4cl-extras/context/file-type.lisp: The log4cl-extras/context/file-type․lisp file
log4cl-extras/error/file-type.lisp: The log4cl-extras/error/file-type․lisp file
log4cl-extras/json/file-type.lisp: The log4cl-extras/json/file-type․lisp file
log4cl-extras/plain/file-type.lisp: The log4cl-extras/plain/file-type․lisp file
log4cl-extras/utils/file-type.lisp: The log4cl-extras/utils/file-type․lisp file

Jump to:   F   L  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   A   F   G   I   L   M   P   R   S   W  
Index Entry  Section

A
apply-args-filters: Internal functions

F
format-frame: Internal functions
from-current-package: Internal functions
Function, apply-args-filters: Internal functions
Function, format-frame: Internal functions
Function, from-current-package: Internal functions
Function, get-backtrace: Internal functions
Function, get-fields: Exported functions
Function, get-timestamp: Exported functions
Function, is-sly-stream: Exported functions
Function, limit-length: Exported functions
Function, make-appender: Internal functions
Function, make-args-filter: Exported functions
Function, make-layout: Internal functions
Function, make-logger: Internal functions
Function, make-placeholder: Exported functions
Function, placeholder-p: Exported functions
Function, prepare: Internal functions
Function, print-backtrace: Exported functions
Function, print-with-indent: Exported functions
Function, remove-newlines: Exported functions
Function, setup: Exported functions
Function, setup-logger: Internal functions
Function, write-json-item: Internal functions
Function, write-plain-item: Internal functions

G
Generic Function, get-timezone: Internal generic functions
Generic Function, get-timezone: Internal generic functions
Generic Function, placeholder-name: Exported generic functions
get-backtrace: Internal functions
get-fields: Exported functions
get-timestamp: Exported functions
get-timezone: Internal generic functions
get-timezone: Internal generic functions
get-timezone: Internal generic functions
get-timezone: Internal generic functions

I
is-sly-stream: Exported functions

L
limit-length: Exported functions

M
Macro, with-fields: Exported macros
Macro, with-log-unhandled: Exported macros
make-appender: Internal functions
make-args-filter: Exported functions
make-layout: Internal functions
make-logger: Internal functions
make-placeholder: Exported functions
Method, get-timezone: Internal generic functions
Method, get-timezone: Internal generic functions
Method, placeholder-name: Exported generic functions

P
placeholder-name: Exported generic functions
placeholder-name: Exported generic functions
placeholder-p: Exported functions
prepare: Internal functions
print-backtrace: Exported functions
print-with-indent: Exported functions

R
remove-newlines: Exported functions

S
setup: Exported functions
setup-logger: Internal functions

W
with-fields: Exported macros
with-log-unhandled: Exported macros
write-json-item: Internal functions
write-plain-item: Internal functions

Jump to:   A   F   G   I   L   M   P   R   S   W  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *   @  
N   S   T  
Index Entry  Section

*
*d*: Internal special variables
*fields*: Internal special variables

@
@configuration: Exported special variables
@context: Exported special variables
@errors: Exported special variables
@intro: Exported special variables
@printing: Exported special variables

N
name: Internal classes

S
Slot, name: Internal classes
Slot, timezone: Exported classes
Slot, timezone: Exported classes
Special Variable, *d*: Internal special variables
Special Variable, *fields*: Internal special variables
Special Variable, @configuration: Exported special variables
Special Variable, @context: Exported special variables
Special Variable, @errors: Exported special variables
Special Variable, @intro: Exported special variables
Special Variable, @printing: Exported special variables

T
timezone: Exported classes
timezone: Exported classes

Jump to:   *   @  
N   S   T  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   C   D   J   L   P   S  
Index Entry  Section

C
Class, dont-disable-mixin: Exported classes
Class, json-layout: Exported classes
Class, placeholder: Internal classes
Class, plain-layout: Exported classes
Class, stable-daily-file-appender: Exported classes
Class, stable-file-appender: Exported classes
Class, stable-this-console-appender: Exported classes

D
dont-disable-mixin: Exported classes

J
json-layout: Exported classes

L
log4cl-extras: The log4cl-extras system
log4cl-extras/appenders: The log4cl-extras/appenders system
log4cl-extras/appenders: The log4cl-extras/appenders package
log4cl-extras/config: The log4cl-extras/config system
log4cl-extras/config: The log4cl-extras/config package
log4cl-extras/context: The log4cl-extras/context system
log4cl-extras/context: The log4cl-extras/context package
log4cl-extras/error: The log4cl-extras/error system
log4cl-extras/error: The log4cl-extras/error package
log4cl-extras/json: The log4cl-extras/json system
log4cl-extras/json: The log4cl-extras/json package
log4cl-extras/plain: The log4cl-extras/plain system
log4cl-extras/plain: The log4cl-extras/plain package
log4cl-extras/utils: The log4cl-extras/utils system
log4cl-extras/utils: The log4cl-extras/utils package

P
Package, log4cl-extras/appenders: The log4cl-extras/appenders package
Package, log4cl-extras/config: The log4cl-extras/config package
Package, log4cl-extras/context: The log4cl-extras/context package
Package, log4cl-extras/error: The log4cl-extras/error package
Package, log4cl-extras/json: The log4cl-extras/json package
Package, log4cl-extras/plain: The log4cl-extras/plain package
Package, log4cl-extras/utils: The log4cl-extras/utils package
placeholder: Internal classes
plain-layout: Exported classes

S
stable-daily-file-appender: Exported classes
stable-file-appender: Exported classes
stable-this-console-appender: Exported classes
System, log4cl-extras: The log4cl-extras system
System, log4cl-extras/appenders: The log4cl-extras/appenders system
System, log4cl-extras/config: The log4cl-extras/config system
System, log4cl-extras/context: The log4cl-extras/context system
System, log4cl-extras/error: The log4cl-extras/error system
System, log4cl-extras/json: The log4cl-extras/json system
System, log4cl-extras/plain: The log4cl-extras/plain system
System, log4cl-extras/utils: The log4cl-extras/utils system

Jump to:   C   D   J   L   P   S