Comments (3)
Hi Ikrubner,
This does look like a concurrency issue. You've got multiple threads all trying to print as quickly as they can, and their output is getting mangled together. Think of a room filled with people all shouting at once: you won't be able to hear what anyone's saying because they're all talking over each other.
In particular, this can happen because prn
, println
, pprint
, etc. call (flush)
whenever they have something to print. In a single-threaded app, that's usually what you want. But for multi-threaded cases like yours, you'd rather have the output buffered and only (flush)
ed as a single atomic output. With the room-of-people analogy, everyone's still shouting together but now at least they're each shouting a complete sentence one at a time without interruption.
I'd start by trying this:
Don't call pprint
3 separate times for each thing you want to output. Each of those 3 calls will (flush)
, meaning other gook can get interleaved in between. Instead, I'd do something like this:
(let [output (with-out-str (pp/pprint prefix) (pp/pprint message) (pp/pprint more))]
(print output)
(flush))
By buffering up the pprint
outputs, that also protects against any flushing that may be happening within the pprint
calls itself (I just skimmed the source now, not sure if that's necessary or not).
In some cases it can also help to enable :async?
for the appender.
Try those out and let me know if you have any luck.
Cheers!
from timbre.
That worked great. Thanks.
from timbre.
Sure, no problem!
from timbre.
Related Issues (20)
- cljs: JS objects are printed uselessly HOT 2
- Update io.aviso/pretty to 1.2 HOT 1
- Support for `nbb` HOT 2
- Community appenders no longer included in 6.0.0 HOT 2
- 6.0.1. breaks in GraalVM native-image HOT 11
- Add test/s re: GraalVM compatibility HOT 1
- Why are my Timbre timezones different than the system ones? HOT 3
- [shadow-cljs] Invalid :refer, var taoensso.encore/have does not exist HOT 26
- IllegalAccessException when logging internal JDK exception (SunCertPathBuilderException) via `log/error` HOT 13
- shadow-cljs: Advanced build bloated since 6.0.3 HOT 6
- Exception thrown when log arguments have same name, but different separators HOT 2
- Timbre crashing Cider workflow (?) HOT 9
- Using TAOENSSO_TIMBRE_CONFIG_EDN environment variable leads to an execption HOT 4
- Need some help/advice: No debug or info level logging, and duplicated message content HOT 10
- Add console appender opt to control `:raw-console?` HOT 1
- Link to Portal Timbre guide HOT 1
- Latest release uses older com.taoensso/encore; order-dependent if used with e.g. Tufte HOT 2
- API docs link from README results in 404 HOT 3
- Graal optimizations may break uberjar running HOT 6
- Seeing a lot of deprecation warnings in our log HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from timbre.