logging: make XLOG_GET_CATEGORY() safe for all callers
Summary:
The `XLOG_GET_CATEGORY()` macro was previously written assuming it was only
used inside `XLOG()` statement. When used inside the main translation unit
being compiled (e.g., a .cpp file and not a header file), the code assumed that
the file-scope category had already been initialized, since a level check had
presumably already been performed.
However, it is useful in some places for external users (outside of the logging
library itself) to call `XLOG_GET_CATEGORY()`. In these cases a log level
check may not have been performed yet, so the file-scope category may not be
initialized yet.
This diff renames the existing `XLOG_GET_CATEGORY()` macro to
`XLOG_GET_CATEGORY_INTERNAL()` and adds a new `XLOG_GET_CATEGORY()` macro that
is slower (it always looks up the category by name) but always safe to use.
This also adds a new `XLOG_GET_CATEGORY_NAME()` macro, and renames the existing
`XLOG_SET_CATEGORY()` macro to `XLOG_SET_CATEGORY_NAME()` for API consistency.
Reviewed By: wez
Differential Revision:
D5269975
fbshipit-source-id:
373805255823855282fa7a8d4a4d232ba06367f6