Skip to content

Structured logging to systemd journal using native systemd libraries and JNA (Java Native Access)

License

Notifications You must be signed in to change notification settings

runejuhl/clj-journal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clj-journal

Structured logging to systemd journal using native systemd libraries and JNA (Java Native Access).

Includes a log appender for timbre.

Features

  • automatically converts hash-maps to journal fields
  • includes timbre output function that removes redundancy in log lines

Installation

[runejuhl/clj-journal "0.3.0"]

Usage

(require '[clj-journal.log :refer [jprint jsend]])
(jprint :error "Oh noes, an error!")
(jsend :emerg
  "Even worse, we got ourselves an emergency!"
  :some-informational-value 9000)

(def debug (jprint :debug))
(debug "This is a bit too verbose to be :info")

Log level conversion

You can override clj-journal.util/level->syslog if you want to use another way of converting a keyword/string reprentation of the log level to an integer:

(binding [clj-journal.util/level->syslog (fn [_] 1)]
  ;; prints as ALERT instead of DEBUG
  (jprint :debug "hello there"))

Logging with Timbre

(timbre/merge-config!
  {:appenders {:journal-appender (clj-journal.timbre/journal-appender)}})

(timbre/info "something happened!" {:asd   12
                                    :leet  1337
                                    :weird {:blegh "lollo"}})

About

Structured logging to systemd journal using native systemd libraries and JNA (Java Native Access)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published