crosvm/base
Noah Gold 7dbdc73063 base & src: allow multiple log inits.
With the migration to env_logger, we lost the ability to initialize
logging multiple times. This meant that we had to wait until we had
parsed CLI args and knew exactly what we wanted our logging spec to be,
which meant that it would sometimes be too late to log startup errors.
This CL modifies the logging facade to be modifiable on the fly, albeit
with some restrictions, to obviate the problem.

The syslog API has been modified as follows:

syslog::early_init: initializes stderr logging, can be called only once
per process. Called as the first function in main.

syslog::init/init_with: can be called after early_init to modify the
parameters used by the logging system. Can be called only once per
process. Will be called roughly after argument parsing or bootstrapping
is complete.

The fundamental change to enable this was in the logging facade. Now,
the facade passes all logging operations to a static, mutex protected
struct. This way, the facade never changes, but we can modify the
struct whenever we wish.

BUG=b:242103548
TEST=tested downstream

Change-Id: I76bc1bb275c81a69aadc7f03a80b94c297f47781
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3834294
Commit-Queue: Noah Gold <nkgold@google.com>
Tested-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-08-19 22:16:46 +00:00
..
base_event_token_derive Reformat imports 2022-07-28 00:15:50 +00:00
src base & src: allow multiple log inits. 2022-08-19 22:16:46 +00:00
.build_test_serial Refactoring: Move common/base into base 2022-03-17 00:01:27 +00:00
Cargo.toml Cargo: bump all rand dependencies to 0.8 2022-06-30 23:22:37 +00:00