amperity / dialog Goto Github PK
View Code? Open in Web Editor NEWSimple just-enough logging library for Clojure
License: MIT License
Simple just-enough logging library for Clojure
License: MIT License
Is there a way to update the logging configuration / levels at runtime without restarting the app?
I imagine this to be useful during long REPL sessions or even in production.
Is there a way to to the same by reloading the config on disk?
This is for OPS where no repl is available / desired.
In unix ops the process is usually:
I think for dialog is enough to implement logic to apply configuration changes.
Loading can happen on the client side.
I've asked this on clojurians slack, on #timbre just now.
We have an issue that I believe is caused by some libraries logging with timbre (not confirmed yet).
In our app if we load dialog ns first, logging works fine.
If we load another ns that uses tools-logging (which should work over slf4j / dialog) then logging from that ns does not appear.
Just started investigating this.
https://clojurians.slack.com/archives/C1J6MQC2H/p1686296806175059
Hi,
I noticed dialog depends on a deps-deploy commit hash that does not exist.
I tried current main.
./bin/build
Error building classpath. Commit not found for slipset/deps-deploy in repo https://github.com/greglook/deps-deploy.git at a138ef59c1239336034c69624458f5b100ac835b
Hi,
We are using timbre and looking at dialog because we can't have unified logging with timbre.
We are using slf4j-timbre but I can't filter out apache loggers.
Also the library is not in sync with timbre and there is also fzakaria/slf4j-timbre#40 .
p.s. Implementing slf4j API I don't expect dialog to work in CLJS as timbre does.
Hi,
I think for some use-cases, event filtering should be done per appender.
I noticed event filtering is done globally (see example in code) .
I remember logback / log4j allows setting the event filtering per appender.
This is explained here for log4j: https://logging.apache.org/log4j/2.x/manual/filters.html
dialog.logger ns doing global filtering with enabled?
(defn log-event
"Pass an event into the logging system."
[event]
(when-not config
(initialize!))
(when-let [event (and (string? (:logger event))
(keyword? (:level event))
(enabled? (:logger event) (:level event))
(-> event
(apply-defaults)
(apply-middleware (:middleware config))))]
(run!
(fn write-event
[[id output]]
(when-let [event (apply-middleware event (:middleware output))]
(write-output! id output event)))
(:outputs config))))
Hi,
I'm using the slf4j branch in a project and I tried to prep it by running clojure -X:deps prep :aliases '[:dev]'
.
However it fails because I am running on jdk-17 and it requires jdk-8.
This makes the library not usable via deps git integration.
The warning should be kept, but the exit should be removed IMO.
For my case it makes no sense - I am building it for my app - all app is built with jdk-17.
The check makes sense only for people doing releases.
(defn javac
"Compile Java source files in the project."
[_]
(let [java-version (System/getProperty "java.version")]
(when-not (str/starts-with? java-version "1.8")
(binding [*out* *err*]
(println "Dialog should be compiled with Java 1.8 for maximum"
"compatibility; currently using:" java-version))
(System/exit 1)))
Before:
bb prep
Downloading: org/clojure/clojure/maven-metadata.xml from central
Downloading: org/clojure/clojure/maven-metadata.xml from clojars
Downloading: org/clojure/clojure/maven-metadata.xml from oss-snapshots-repo
Prepping amperity/dialog in /home/ieugen/.gitlibs/libs/amperity/dialog/d6569524ddc6f93eee9076054d9aa7887c8555fc
Dialog should be compiled with Java 1.8 for maximum compatibility; currently using: 17.0.5
Execution error (ExceptionInfo) at clojure.tools.deps/prep-libs!$fn (deps.clj:711).
Prep function could not be resolved: build/javac
Full report at:
/tmp/clojure-17842702112232980049.edn
Error while executing task: prep
After:
bb prep
Checking out: https://github.com/ieugen/dialog at 50fdfd3bacf4e86f1b82b3a9a3ea5e14fdbf974f
Prepping amperity/dialog in /home/ieugen/.gitlibs/libs/amperity/dialog/50fdfd3bacf4e86f1b82b3a9a3ea5e14fdbf974f
Dialog should be compiled with Java 1.8 for maximum compatibility; currently using: 17.0.5
โ prep
slf4j 2.0 uses ServiceLoader mechanism instead of older loading mechanism.
This makes it compatible with Java 9 module system.
I would like to use this library but we use Sentry and we would need a sentry appender.
Does this library support this kind of extension?
I did not see anything in the docs.
The outputs seem to be a fixed list.
Nothing about adding your own: db, sentry, etc.
Will be nice to merge two or maybe more config files.
I mean I have my own framework library with one dialog config. I want it to be default one for projects using this framework. And in final projects I want just reassign some config values. Is it possible? Now I have to copy/paste whole config and it is not very convient.
In docs and examples you using middleware and initialize! function from acme.logging package. But I can't find something like that anywhere in internet. Please, clarify it. Thank you.
Dialog does not correctly format log messages using SLF4J "brace style" substitution parameters:
dialog.repl=> (log/infof "{}, {}!" "hello" "world")
00:20:17.755 [nREPL] INFO dialog.repl {}, {}!
Internally, dialog uses String.format
, but should be using org.slf4j.helpers.MessageFormatter
.
tools-deps has a feature to consume libraries directly from git.
Providing a deps.edn file will allow proejcts to consume unreleased version of dialog
and facilitate testing.
Hi @greglook ,
I think I found a bug, related to : #23
I tried with initialize!
and I can't seem to mask "com.zaxxer.hikari.util.DriverDataSource" .
Setting the level via (dialog.logger/set-level! "com.zaxxer.hikari.util.DriverDataSource" :info)
works just fine.
p.s. I tried with both dialog commit 1dda8ccdd5172113c126df2a0c5dd1ae31332127 and also my slf4j-2 branch.
I have a project that uses github.com/stuartsierra/component and hikari db pooling library.
I start the app and I see this line:
13:11:16.041 [nREPL] DEBUG com.zaxxer.hikari.util.DriverDataSource Loaded driver with class name org.postgresql.Driver for jdbcUrl=REDACTED
initialize!
and checked config is loaded in dialog.logger/config .Adding line to dialog.edn + reloading config does not change logging in existing repl.
Repl needs to be restarted for this to work.
{ :level :debug
:levels {"dre" :info
"io.netty" :info
"com.zaxxer.hikari.pool" :info
"org.apache.jena" :info
"com.amazonaws" :info
"com.zaxxer.hikari.HikariConfig" :error
}
:blocked #{"org.apache.http"
"org.apache.parquet"
"software.amazon.awssdk.profiles.internal.ProfileFileReader"
"com.amazonaws.auth.profile.internal.BasicProfileConfigLoader"}
:outputs {:dev {:type :print
:stream :stdout
:format :pretty
:padding false
:timestamp :short}}}
My deps.edn :
amperity/dialog {:git/url "https://github.com/amperity/dialog"
:sha "1dda8ccdd5172113c126df2a0c5dd1ae31332127"}
org.slf4j/log4j-over-slf4j {:mvn/version "1.7.30"}
org.slf4j/jul-to-slf4j {:mvn/version "1.7.30"}
org.slf4j/jcl-over-slf4j {:mvn/version "1.7.30"}
{:jvm-opts [ "REDACTED"
"-Dclojure.tools.logging.factory=clojure.tools.logging.impl/slf4j-factory"]}
For long running apps that write to disk it might be good to have rolling file appenders.
There is a good overview of these in https://www.baeldung.com/java-logging-rolling-file-appenders .
I'm also wondering if it's possible to use existing slf4j appender implementations in dialog ?!
This might be hard if they are bundled with slf4j implementation - like logback has it's appenders.
But there are appenders out there that might not be.
Running the tests on my system, I have a failure because of the decimal separator in (123,456 ms)
.
FAIL in dialog.format.simple-test/message-formatting (simple_test.clj:38)
with duration
Expected:
"2021-12-27T15:33:18Z [main] WARN foo.bar.baz Another thing (123.456 ms)"
Actual:
-"2021-12-27T15:33:18Z [main] WARN foo.bar.baz Another thing (123.456 ms)"
+"2021-12-27T15:33:18Z [main] WARN foo.bar.baz Another thing (123,456 ms)"
28 tests, 210 assertions, 2 failures.
Any reason that this bridge is not included ?
I would hope to get a "once-for-ever" solution which bridges everything into "slf4j"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.