An open API service indexing awesome lists of open source software.

https://github.com/runejuhl/clj-journal

Structured logging to systemd journal using native systemd libraries and JNA (Java Native Access)
https://github.com/runejuhl/clj-journal

clojure java-native-access journald logging structured-logging

Last synced: 3 months ago
JSON representation

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

Awesome Lists containing this project

README

        

* 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

#+BEGIN_SRC clojure
[runejuhl/clj-journal "0.3.0"]
#+END_SRC

** Usage

#+BEGIN_SRC clojure
(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")
#+END_SRC

*** 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:

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

*** Logging with Timbre

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

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