Timbre corrupting EDN via prn-str

86 views
Skip to first unread message

Ken Restivo

unread,
Oct 7, 2015, 4:18:50 AM10/7/15
to clo...@googlegroups.com
I was trying to save a data structure using prn-str.

However, I'm also using Timbre for logging.

My nice data structure is getting corrupted by INFO and DEBUG and other log messages from Timbre.

Is there any way to turn a Clojure data structure into EDN without mucking around with things like pr-str that use *out*, which apparently is used for logging, among other things?

-ken

Atamert Ölçgen

unread,
Oct 7, 2015, 4:31:45 AM10/7/15
to clo...@googlegroups.com
Hi Ken,

Have you tried with-out-str?

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Kind Regards,
Atamert Ölçgen

◻◼◻
◻◻◼
◼◼◼

www.muhuk.com

Ken Restivo

unread,
Oct 7, 2015, 4:37:10 AM10/7/15
to clo...@googlegroups.com
Yep. It doesn't help.

I also tried (.flush *out*) before... no dice.

-ken
--
-----

Atamert Ölçgen

unread,
Oct 7, 2015, 4:45:40 AM10/7/15
to clo...@googlegroups.com
So you actually want to print your data. I don't think it can be helped then, two threads writing to the same buffer. I would have one of them use a different buffer, write the logs to a file and tail it for instance.

Ken Restivo

unread,
Oct 7, 2015, 4:50:57 AM10/7/15
to clo...@googlegroups.com
I've dug into this more, and it seems there's a third factor at work: conch.

In one of the functions called before this data is written, conch is shelling out to a command. Obviously it's also mucking around with stdin/stdout/stderr.

Only when conch is called, is this error generated. Not shelling out makes the problem go away. So it's an interaction between pr-str, conch and/or clojure.java.shell, and Timbre-- all three of which are manipulating *out* which I'm guessing is not thread-safe.

I don't know the solution yet but starting to understand the problem anyway.

-ken
--
-------

Tassilo Horn

unread,
Oct 7, 2015, 5:58:46 AM10/7/15
to Ken Restivo, clo...@googlegroups.com
Ken Restivo <k...@restivo.org> writes:

> Only when conch is called, is this error generated. Not shelling out
> makes the problem go away. So it's an interaction between pr-str,
> conch and/or clojure.java.shell, and Timbre-- all three of which are
> manipulating *out* which I'm guessing is not thread-safe.

You can use `(write my-data :stream my-custom-writer)` to write your
data elsewhere than `*out*`.

Bye,
Tassilo
Reply all
Reply to author
Forward
0 new messages