Giter Site home page Giter Site logo

Use Timber. and L. together about lumberjack HOT 8 CLOSED

mflisar avatar mflisar commented on May 23, 2024
Use Timber. and L. together

from lumberjack.

Comments (8)

MFlisar avatar MFlisar commented on May 23, 2024

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(...)...

from lumberjack.

Isanderthul avatar Isanderthul commented on May 23, 2024

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);

from lumberjack.

Isanderthul avatar Isanderthul commented on May 23, 2024

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).

from lumberjack.

MFlisar avatar MFlisar commented on May 23, 2024

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...

from lumberjack.

Isanderthul avatar Isanderthul commented on May 23, 2024

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

from lumberjack.

MFlisar avatar MFlisar commented on May 23, 2024

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)

from lumberjack.

MFlisar avatar MFlisar commented on May 23, 2024

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

from lumberjack.

MFlisar avatar MFlisar commented on May 23, 2024

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...

from lumberjack.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.