Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .github/dependabot.yml

This file was deleted.

59 changes: 57 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ concurrency:
cancel-in-progress: true

jobs:
mokujin-test:
mokujin:
name: Test mokujin core
runs-on: ubuntu-latest
timeout-minutes: 10

Expand All @@ -22,18 +23,72 @@ jobs:
uses: actions/cache@v5
with:
path: /root/.m2
key: v1-deps-${{ hashFiles('./mokujin/deps.edn') }}-${{ hashFiles('./mokujin-logback/deps.edn') }}
key: v1-deps-mokujin-${{ hashFiles('mokujin/deps.edn') }}

- name: Run core tests
run: cd mokujin && clj -M:dev:test:run-tests
env:
TZ: UTC

mokujin-logback:
name: Test mokujin-logback
runs-on: ubuntu-latest
timeout-minutes: 10
needs: mokujin

container:
image: clojure:openjdk-17-tools-deps-slim-buster

steps:
- uses: actions/checkout@v5

- name: Cache Clojure deps
uses: actions/cache@v4
with:
path: /root/.m2
key: v1-deps-mokujin-logback-${{ hashFiles('mokujin-logback/deps.edn') }}

- name: Run logback extensions tests
run: cd mokujin-logback && clj -M:dev:test:run-tests

logback-example:
name: Verify logback example
runs-on: ubuntu-latest
timeout-minutes: 10
needs: mokujin

container:
image: clojure:openjdk-17-tools-deps-slim-buster

steps:
- uses: actions/checkout@v5

- name: Cache Clojure deps
uses: actions/cache@v4
with:
path: /root/.m2
key: v1-deps-logback-example-${{ hashFiles('examples/logback/deps.edn') }}

- name: Verify logback example
run: cd examples/logback && clj -M:run

log4j2-example:
name: Verify log4j2 example
runs-on: ubuntu-latest
timeout-minutes: 10
needs: mokujin

container:
image: clojure:openjdk-17-tools-deps-slim-buster

steps:
- uses: actions/checkout@v5

- name: Cache Clojure deps
uses: actions/cache@v4
with:
path: /root/.m2
key: v1-deps-log4j2-example-${{ hashFiles('examples/log4j2/deps.edn') }}

- name: Verify log4j2 example
run: cd examples/log4j2 && clj -M:run
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,41 @@ SNAPSHOT ?= false
LIB = mokujin mokujin-logback

clean:
$(foreach lib,$(LIB),clj -T:build clean :lib $(lib);)
$(foreach lib,$(LIB),clojure -T:build clean :lib $(lib);)

jar:
$(foreach lib,$(LIB),clj -T:build jar :lib $(lib) :snapshot $(SNAPSHOT);)
$(foreach lib,$(LIB),clojure -T:build jar :lib $(lib) :snapshot $(SNAPSHOT);)


install:
$(foreach lib,$(LIB),clj -T:build install :lib $(lib) :snapshot $(SNAPSHOT);)
$(foreach lib,$(LIB),clojure -T:build install :lib $(lib) :snapshot $(SNAPSHOT);)

publish: clean jar
$(foreach lib,$(LIB),clj -T:build publish :lib $(lib) :snapshot $(SNAPSHOT);)
$(foreach lib,$(LIB),clojure -T:build publish :lib $(lib) :snapshot $(SNAPSHOT);)

# Dev/test tasks


update-deps:
$(foreach lib,$(LIB),cd $(lib) && clj -M:dev/outdated && cd -;)
$(foreach lib,$(LIB),cd $(lib) && clojure -M:dev/outdated && cd -;)

test-all: test-core test-logback test-ex-logback test-ex-log4j2
@echo "all done"

test-core:
cd mokujin && clj -M:dev:test:run-tests
cd mokujin && clojure -M:dev:test:run-tests

test-logback:
cd mokujin-logback & clj -M:dev:test:run-tests
cd mokujin-logback && clojure -M:dev:test:run-tests

test-ex-logback:
cd examples/logback && clj -M:run
cd examples/logback && clojure -M:run

test-ex-log4j2:
cd examples/log4j2 && clj -M:run
cd examples/log4j2 && clojure -M:run

benchmark:
cd bench && clj -M:benchmark
cd bench && clojure -M:benchmark


help:
Expand Down
8 changes: 4 additions & 4 deletions mokujin-logback/deps.edn
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{:paths ["src"]
:deps {org.clojure/data.xml {:mvn/version "0.2.0-alpha9"}
ch.qos.logback/logback-classic {:mvn/version "1.5.20"
:deps {org.clojure/data.xml {:mvn/version "0.2.0-alpha10"}
ch.qos.logback/logback-classic {:mvn/version "1.5.24"
:exclusions [org.slf4j/slf4j-api]}
net.logstash.logback/logstash-logback-encoder {:mvn/version "8.1"}}
net.logstash.logback/logstash-logback-encoder {:mvn/version "9.0"}}

:aliases {:dev {:extra-paths ["dev-resources"]
:jvm-opts ["-XX:-OmitStackTraceInFastThrow"
Expand All @@ -17,6 +17,6 @@

:run-tests {:main-opts ["-m" "kaocha.runner"]}

:build {:deps {io.github.clojure/tools.build {:mvn/version "0.10.10"}
:build {:deps {io.github.clojure/tools.build {:mvn/version "0.10.12"}
slipset/deps-deploy {:mvn/version "0.2.2"}}
:ns-default build}}}
6 changes: 3 additions & 3 deletions mokujin/deps.edn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{:paths ["src" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.12.3"}
org.clojure/tools.logging {:mvn/version "1.3.0"}
:deps {org.clojure/clojure {:mvn/version "1.12.4"}
org.clojure/tools.logging {:mvn/version "1.3.1"}
org.slf4j/slf4j-api {:mvn/version "2.0.17"}}

:aliases {:dev {:extra-paths ["dev-resources" "test"]
Expand All @@ -17,6 +17,6 @@

:run-tests {:main-opts ["-m" "kaocha.runner"]}

:build {:deps {io.github.clojure/tools.build {:mvn/version "0.10.10"}
:build {:deps {io.github.clojure/tools.build {:mvn/version "0.10.12"}
slipset/deps-deploy {:mvn/version "0.2.2"}}
:ns-default build}}}
18 changes: 8 additions & 10 deletions mokujin/test/mokujin/log_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
kaocha.plugin.capture-output
[clojure.string :as str]
[clojure.test :refer [deftest is testing]]
[matcher-combinators.test]
[matcher-combinators.core :refer [match?]]
[matcher-combinators.test :refer [match?]]
[mokujin.log :as log])
(:import
(org.slf4j MDC)))
Expand Down Expand Up @@ -91,10 +90,10 @@
(deftest nested-contexts
(log/with-context {:level-zero "0"}
(run-in-thread
(fn nested' []
(log/with-context {:level-one "yes"}
(log/with-context {:level-two "yes"}
(log/info "ahem" {:level-three "yes"}))))))
(fn nested' []
(log/with-context {:level-one "yes"}
(log/with-context {:level-two "yes"}
(log/info "ahem" {:level-three "yes"}))))))

(let [captured-logs (parse-captured-logs)]
(testing "contexts can be nested, but only work within current thread"
Expand Down Expand Up @@ -139,7 +138,7 @@
(log/error "five"))
(log/with-context {:foo :bar}
(try
(throw (ex-info "this is exception" {}))
(throw (ex-info "this is exception" {:with "data"}))
(catch Exception e
(log/error e "six" {:fail true})))))
(log/info "seven")))
Expand All @@ -156,16 +155,15 @@
{:nested "again" :foo "bar"}
{:fail "true" :nested "again" :foo "bar"}
{}]
captured-logs #_(map #(dissoc % :message :level :stack_trace)
captured-logs))))
captured-logs)))
(testing "stack trace is included"
(is (match? [{:fail "true"
:nested "again"
:foo "bar"
:level "ERROR"
:message "six"
:stack_trace {:count 5
:message "clojure.lang.ExceptionInfo: this is exception"}}]
:message "clojure.lang.ExceptionInfo: this is exception {:with \"data\"}"}}]
(filter :stack_trace captured-logs))))))

(deftest verify-nested-mdc
Expand Down