opendal icon indicating copy to clipboard operation
opendal copied to clipboard

feat(binding/c): Add support for logging and other layers.

Open jiaoew1991 opened this issue 2 years ago • 6 comments

I am trying to integrate C binding into our project and encountered some errors. The error message only contains an error code, so I cannot determine the specific cause of the error. After using some hacky methods, I found the reason for the error, but it is not very user-friendly for developers.

There are many layers in opendal core, including logging, but C binding cannot use these layers yet. I hope to add support for them.

In addition, there are no dependencies on log and env-logging in c binding's cargo. After adding these dependencies, logging can be printed correctly. I hope that c binding can add a method like "opendal_init_logger" to allow users to adjust the logging settings.

jiaoew1991 avatar Jul 20 '23 10:07 jiaoew1991

I perfer to integrate tools that existing in c or cpp ecosystem, like glog. Using tracing or env-logger in c/cpp projects seems not a good idea.

Xuanwo avatar Jul 20 '23 10:07 Xuanwo

Just out of curiosity, @jiaoew1991, would you prefer a C++ binding instead of C?

Xuanwo avatar Jul 20 '23 10:07 Xuanwo

Just out of curiosity, @jiaoew1991, would you prefer a C++ binding instead of C?

If there is a C++ version, it would be better, but if not, it won't affect the usage much. 😄

jiaoew1991 avatar Jul 20 '23 10:07 jiaoew1991

I perfer to integrate tools that existing in c or cpp ecosystem, like glog. Using tracing or env-logger in c/cpp projects seems not a good idea.

If use an external tool like glog, how can I make the logs inside opendal core be printed out? 🤔

jiaoew1991 avatar Jul 20 '23 10:07 jiaoew1991

If use an external tool like glog, how can I make the logs inside opendal core be printed out?

There are something the we need to do in bindings:

  • Use glog to implement tracing-subscribe so they can collect log print by opendal core
  • Implement C binding's own GlogLayer to allow users to switch betweeen different logging tools.

In this way, our users of c/cpp binding can integrate their native logging tools.

Xuanwo avatar Jul 20 '23 10:07 Xuanwo

If use an external tool like glog, how can I make the logs inside opendal core be printed out?

There are something the we need to do in bindings:

  • Use glog to implement tracing-subscribe so they can collect log print by opendal core
  • Implement C binding's own GlogLayer to allow users to switch betweeen different logging tools.

In this way, our users of c/cpp binding can integrate their native logging tools.

We use glog in our project, which is great as it reduces dependencies.

jiaoew1991 avatar Jul 20 '23 10:07 jiaoew1991