abseil/abseil-py

How to turn on vlog for a specific file?

skye opened this issue · 2 comments

skye commented

The -v flag can be used to enable vlog messages across all files, but is it possible to enable only for a specific file(s)? I think the C++ logging library uses --vmodule but there's no such flag for Python, even though a comment in the code says it should be possible: https://github.com/abseil/abseil-py/blob/master/absl/logging/__init__.py#L53

(BTW it'd be great to document the -v flag somewhere, it took me a while to figure that one out.)

yilei commented

We don't have Abseil C++ logging integration (yet) so there is no --vmodule with absl.logging and you can't control per file.

We do have a separate per-logger control (instead of per-file) of levels, so if you use different loggers you can control with the --logger_levels flag:

flags.DEFINE_flag(
_LoggerLevelsFlag(
'logger_levels', {},
'Specify log level of loggers. The format is a CSV list of '
'`name:level`. Where `name` is the logger name used with '
'`logging.getLogger()`, and `level` is a level name (INFO, DEBUG, '
'etc). e.g. `myapp.foo:INFO,other.logger:DEBUG`'))

skye commented

Thanks for the fast reply! I guess consider this a feature request for something akin to --vmodule then :) Using -v for now works well enough (which is realistically what I'll do instead instead of creating per-module loggers, although that would be the more "proper" thing to do).