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)
- Host: GitHub
- URL: https://github.com/runejuhl/clj-journal
- Owner: runejuhl
- License: epl-2.0
- Created: 2017-11-23T22:29:20.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-04-04T08:49:06.000Z (about 3 years ago)
- Last Synced: 2025-02-28T17:08:38.860Z (3 months ago)
- Topics: clojure, java-native-access, journald, logging, structured-logging
- Language: Clojure
- Size: 67.4 KB
- Stars: 4
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.org
- Changelog: CHANGELOG.md
- License: LICENSE
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