Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

could u support timbre log library #83

Open
vinurs opened this issue Dec 9, 2022 · 10 comments
Open

could u support timbre log library #83

vinurs opened this issue Dec 9, 2022 · 10 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@vinurs
Copy link
Contributor

vinurs commented Dec 9, 2022

hello,
i usually use timebre instead of tools/logging
another question: how to log the current file line when use tools.logging

@yogthos
Copy link
Collaborator

yogthos commented Dec 9, 2022

I think it should be possible to add timbre as an option to the template. It would be a matter of changing the dependency and the config files. And not sure about adding line numbers outside exceptions.

@yogthos yogthos added enhancement New feature or request help wanted Extra attention is needed labels Dec 9, 2022
@nikolap
Copy link
Member

nikolap commented Dec 10, 2022

I also believe it's possible to get clojure.tools.logging to log out to Timbre via https://github.com/ptaoussanis/timbre/blob/master/src/taoensso/timbre/tools/logging.clj#L38

Note: I haven't tried this, so if you do get it working would be worth commenting back since it might be nice to have it as a template option, or module

@vinurs
Copy link
Contributor Author

vinurs commented Apr 26, 2023

@nikolap yes, it can works, but it can not show line number, the reason i want to use timbre is that clojure.tools.logging can not show line number in clj file

2023-04-27 07:40:39 CST vinursdeMacBook-Pro.local INFO [user:?] - clojure.tools.logging can not show line number
2023-04-27 07:40:40 CST vinursdeMacBook-Pro.local INFO [user:86] - timber can show line number

@nikolap
Copy link
Member

nikolap commented Apr 30, 2023

I'm not familiar with Timbre, however clojure.tools.logging wraps your chosen Java logging provider. e.g. logback is the default one. Perhaps one of these supports your request.

Based off of how Timbre implements it, you could do something like this https://www.reddit.com/r/Clojure/comments/sxwmt9/how_to_log_line_numbers_with_toolslogging/

Hope that helps

@vinurs
Copy link
Contributor Author

vinurs commented Apr 30, 2023

@nikolap thanks, it says
just add to your entry point namespace:
then ,what's the entry point namespace of luminus and kit-clj , i put it in the app.core, but i found in some namespace it doesn't affect when the server start up

@nikolap
Copy link
Member

nikolap commented May 1, 2023

Yes, the core namespace would be the entry point.

I didn't try the reddit answer extensively, so you may need to tweak it, e.g. to support levels beside INFO. But it certainly worked from the REPL.

However, it won't work for logging produced by non- clojure.tools.logging calls since it's a redef of log/info.

Maybe there's also other ways to enable log numbers in one of the clojure.tools.logging supported logging implementations.

@vinurs
Copy link
Contributor Author

vinurs commented May 3, 2023

i tested , maybe the entry point namespace of kit-clj should be config.clj , now everything works as expect

@yogthos
Copy link
Collaborator

yogthos commented May 3, 2023

might be worth updating the template to do this by default

@vinurs
Copy link
Contributor Author

vinurs commented May 4, 2023

OK, i will send a pr later, how can i test in my pc?

bb publish-local
+ clojure -T:build install-lib :artifact-id
Unreadable arg: ""
Error while executing task: publish-local

@yogthos
Copy link
Collaborator

yogthos commented May 4, 2023

you can try running clojure -T:build install-libs instead. For publish-local you have to give it the id of the lib to publish, you can do publish-all-local instead. There are a few examples on the wiki here https://github.com/kit-clj/kit/wiki

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants