Coder Social home page Coder Social logo

Comments (5)

JiamingFB avatar JiamingFB commented on April 26, 2024

Currently the logging is only for debugging purpose.
You can actually simply override print() in PrintStream, and redirect the output to slf4j, then you can use whichever framework you want.

from facebook-java-business-sdk.

kilink avatar kilink commented on April 26, 2024

Currently the logging is only for debugging purpose.

Isn't that what most logging is for?

You can actually simply override print() in PrintStream, and redirect the output to slf4j, then you can use whichever framework you want.

Okay, but that's the whole point of slf4j; it's simply a facade which lets the consumer supply the logging framework of her choice.

Using slf4j has other advantages:

  • You don't need a separate debug flag.
  • The consumer can have finer grained control over what to log and when. For example, while debugging an issue, one might log everything, but in steady state just log errors to avoid polluting the logs.
  • String formatting support in slf4j and similar logging frameworks avoid allocating unnecessary objects when the message is simply discarded. Here is an example. Granted, it may not be significant in most cases, but some people like to avoid unnecessary garbage.
  • Customization of the message format. The consumer can choose to log timestamps, and other auxiliary information.
  • No need for special configuration (like your suggestion to create a PrintStream class). A consumer's other dependencies will typically have their logging configured in one place.

Maybe you think it's overkill, or don't want to add the dependency? I can already see a need for separate log levels, since as is there is only a single flag, so you either get a huge amount of information, or none at all. Additionally, as the library grows, so will the need to log different kinds of information (exceptions, warnings, etc). And regarding adding a dependency, I am going to guess that the vast majority of consumers already depend on slf4j, either directly or transitively. If this is a serious impediment, then I think even using java.util.logging would be a better option.

To be clear, I'm not asking anyone to do this work. I'll gladly contribute the PR for this (and any other issues I've opened). First I just want to figure out whether it will be accepted or not :-)

from facebook-java-business-sdk.

JiamingFB avatar JiamingFB commented on April 26, 2024

Hi kilink,

I actually agree that the logging needs improvement. Current logging is only for SDK debugging to check if the HTTP request is assembled and sent correctly, so it's not well structured. I think many people do want to log and archive all the requests they send in a better structure (maybe a JSON string like {"request": {...}, "response": {...}} ?), which is not supported right now but would be great to have, and in this case slf4j will be a good choice. I think slf4j is lightweight so I'm not worried about dependency.

This project is open-source and we're happy to see people contribute to it. You're more than welcome to make contributions :)

Thanks!

from facebook-java-business-sdk.

nemccarthy avatar nemccarthy commented on April 26, 2024

+1

from facebook-java-business-sdk.

codytwinton avatar codytwinton commented on April 26, 2024

It seems like this issue has been open for more than a few months now. We have made many changes in the SDK since then, including releasing a new version. If you can repro your specific issue with the latest version of the SDK, please create a new issue or comment here with further details.

from facebook-java-business-sdk.

Related Issues (20)

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.