dmlc / dmlc-core

A common bricks library for building scalable and portable distributed machine learning.
Apache License 2.0
865 stars 520 forks source link

[Feature] Logging level support #623

Open szha opened 4 years ago

szha commented 4 years ago

Since dmlc-core logging is providing logging capability to several projects, it would be great to have the capability of setting logging levels which will improve the user experience in these projects.

https://github.com/apache/incubator-mxnet/issues/16666 https://github.com/apache/incubator-mxnet/issues/10492

The implementation should allow changing the logging level at runtime, and for disabled logging levels, the invocation should incur as little overhead as possible.

hcho3 commented 4 years ago

@trivialfis This is a good time to port dmlc/xgboost#3982 to dmlc-core. I'd like to give it a try.

trivialfis commented 4 years ago

Not sure about that. I have a similar logging utility for my own use with some additional features like signal handling (printing a backtrace when segfault). But the more I use logging, the more I like about Python's logging module. If you want to create a new c++ logging library, I suggest we can look into that direction a little bit.

hcho3 commented 4 years ago

I agree that Python logging is nice. However, we need need logging in the C++ layer. Also, there is a large body of existing code using LOG(INFO). That's why I'm inclined to port dmlc/xgboost#3982 to dmlc-core.

If you want to create a new c++ logging library, I suggest we can look into that direction a little bit.

Do you see a clear design flaw in dmlc/xgboost#3982?

trivialfis commented 4 years ago

@hcho3

Do you see a clear design flaw in dmlc/xgboost#3982?

Not yet, maybe no support for user defined verbosity level?

we need need logging in the C++ layer.

Yup, I meant we can implement something similar to python logging in c++. We can use shared pointer for holding child logger, define a similar logger manager etc. I haven't found any existing implementation online. But I believe it's possible.

lso, there is a large body of existing code using LOG(INFO). That's why I'm inclined to port dmlc/xgboost#3982 to dmlc-core.

Sure, that won't be a problem. But since dmlc-core is a common brick for other libraries. Giving it some more thought would be great.