Skip to content

Commit

Permalink
Make the logging macros produced by deflevel multi-arity (#1)
Browse files Browse the repository at this point in the history
* make deflevel macro multi-arity
  • Loading branch information
louiseklodt-kroo authored Feb 16, 2024
1 parent 8de3432 commit 62878a9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ The core of any logging tool is being able to make logs:

;; Programatically log at different levels with `log`.
(log/log :warn "Warning about something" {:what? "something..."})

;; Just log a message without data or options.
(log/info "This is just a log message")
```


Expand Down
2 changes: 1 addition & 1 deletion build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ If there was no Git tag pointing to the commit, the jar will have the version: `

## Deploy

Create a Git tag for the version to build (preferrably prefixed with `v`) pointing at the relevant commit.
Create a Git tag for the version to build (preferably prefixed with `v`) pointing at the relevant commit.

Run this command (replacing the username and password with your own and the version with the Git tag), which will test, build and deploy the jar to Clojars.

Expand Down
2 changes: 1 addition & 1 deletion examples/logback/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ This is an example Clojure project demonstrating how to use Epilogue (logging fr

[Logback]: https://logback.qos.ch

It is using [Typeset.logback](https://github.com/b-social/typeset.logback) as the log formatter for Logback as it supports all of Epilogue's features and has excellent Clojure support.
It is using [Typeset.logback](https://github.com/b-social/typeset.logback) as the log formatter for Logback as it supports all of Epilogue's features and has excellent Clojure support.
5 changes: 5 additions & 0 deletions examples/logback/src/com/example/logging/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@
(SLF4JBridgeHandler/install)

(log/info "Log!" {:foo "bar"})

(defn run [& args]
(log/info "Log!" {:foo "bar"})
(log/info "Log no data!"))

7 changes: 5 additions & 2 deletions src/com/kroo/epilogue.clj
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
forms)]
(when (seq idxs) idxs)))

; TODO change name to add-file-and-namespace ?
(defn- preserve-form-meta [body]
`(with-meta ~body
(assoc (meta ~'&form) :file (str *file*), :namespace (str *ns*))))
Expand Down Expand Up @@ -170,8 +171,10 @@
" - a sequence of SLF4J `markers` (or strings/keywords), and\n"
" - an override logger namespace (`logger-ns`).")
:arglists '~'([msg data & {:keys [cause markers logger-ns]}])}
[msg# data# & opts#]
`(log ~~(keyword level) ~msg# ~data# ~@opts#)))
([msg#]
`(log ~~(keyword level) ~msg# {}))
([msg# data# & opts#]
`(log ~~(keyword level) ~msg# ~data# ~@opts#))))

;; Generate convenience macros for the supported logging levels.
(declare error warn info debug trace)
Expand Down

0 comments on commit 62878a9

Please sign in to comment.