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

Use Timber. and L. together #2

Closed
Isanderthul opened this issue Feb 6, 2017 · 8 comments
Closed

Use Timber. and L. together #2

Isanderthul opened this issue Feb 6, 2017 · 8 comments

Comments

@Isanderthul
Copy link

it would be nice if I can separate the use of L. to log to file, and Timber. as normal (not logging to file) (to prevent #1). Logging to file is why I tried Lumberjack.

@MFlisar
Copy link
Owner

MFlisar commented Feb 6, 2017

Why do you actually want to do that? So that you don't have to change your code?

Otherwise, there is no real difference in logging via L.d(...) or via Timber.d(...)...

@Isanderthul
Copy link
Author

Yes, it is so that I don't have to change, and also I just wanted the file logging capabilities of L. at the moment I am using another library, I wanted to save my data transactions like this...

Timber.d("uploading json " + bodyApi);
XLog.d("uploading json " + bodyApi);

@Isanderthul
Copy link
Author

so I think a method to console log, and a separate method to file log would be cool, something like
L.d behaves like Timber.d console only, and L.f logs to file and console. Also I had trouble finding L.i (maybe this is a separate issue).

@MFlisar
Copy link
Owner

MFlisar commented Feb 7, 2017

Actually, this is defeating one of Timbers features, registering trees and don't think about them anymore. Timber just logs to all registered trees automatically.

Writing 2 lines for each debug line is annoying, isn't it?

What you could try is following: write your own logToConsoleOnly function like following:

  • unregister the file logger
  • use L.d
  • register the file logger again

PS: L.i is just not written yet, I always log at debug level. I'll add this, I just need to write the few forwarding functions from L to Timber...

@Isanderthul
Copy link
Author

true enough. I think then we can close this issue as well. Thank you for being so quick to respond!

@MFlisar
Copy link
Owner

MFlisar commented Feb 7, 2017

You need to adjust the stack trace depth in this function, because your wrapping function will add one level to it...

So in this function you'll need to call L.d(ILogGroup group, int callStackCorrection, String message, Object... args) to take care of this...

I'll update the library today and add following:

  • I'll add this function: L.d(int callStackCorrection, String message, Object... args) so you can use this function in your function
  • I'll add the missing log levels (i, w, v)

@MFlisar
Copy link
Owner

MFlisar commented Feb 7, 2017

Done. You can try https://github.com/MFlisar/Lumberjack/releases/tag/1.3 now...

@MFlisar
Copy link
Owner

MFlisar commented Mar 1, 2017

New version v2 supports filtering on a per tree base, just pass in a https://github.com/MFlisar/Lumberjack/blob/master/library/src/main/java/com/michaelflisar/lumberjack/filter/ILogFilter.java to the tree constructors that filters out any group or priority you don't want to log with the tree...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants