This commit adds a new initialization priority `FreezeNamespaces` that is run
last and moves all calls to `Namespace::Freeze()` there. This allows all other
initialization functions to still update namespaces without the use of the
`overrideFrozen` flag.
It also moves the initialization of `System.Platform*` and `System.Build*` to
an initialize function so that these can also be set without setting
`overrideFrozen`.
This is preparation for a following commit that will make the frozen flag in
namespaces finial, no longer allowing it to be overriden (freezing the
namespace will disable locking, so performing further updates would be unsafe).
by caching the total minimum log severity of all loggers in a
"global variable" and whether a message's severity is large enough for any of
the loggers in a per-message no-op flag.
The point of logging to the Windows Event Log was to catch errors that happen
before the full logging configuration has been loaded and enabled. Messages
like the number of loaded objects per type just cause noise in the log and
provide little benefit. Therefore raise the required log level at this stage.
Note that this commit removes the (never documented) ability to use the -x flag
to change the level. But doing so would require patching the command line of
the service in the registry anyways.
When Icinga 2 is started as a service, the early log messages generated
until the FileLogger object is activated are lost and make it really
hard to debug issues that (only) occur when Icinga 2 reloads.
With this commit, these early log messages are written to the Windows
Event Log.
It's called "Console", which would be line-buffered anyway. But, it's
implemented as std::cout. This might be piped to a logger, as in
daemontools or systemd. In this case it will not be a TTY, and log lines
should be flushed without too much delay. Let's just flush each message.
Let's not introduce a static instance of StreamLogger (flushed by interval
timer). That's too stressful to read, because static instances are really
annoying to order. Example citation: "Yay, our static destructors are
pretty much beyond repair at this point." -- application.cpp.
I don't know if there will be any need to optimize logging syscalls. The
init script uses `--daemonize`. I think the systemd service should also
avoid using the "Console" log after startup (see next commit). The
documentation does not warn that the syslog feature is less efficient
in system calls than mainlog; deferred flusing does not seem to be a highly
prominent feature. There's no cool comment in the code about how much the
syscalls were slowing down some use case (or qualifying that this
optimization can only eliminate syscalls on platforms with both mutexes and
clocks that can work without syscalls).
What does this change?
* Remove use of spaces for formatting
These could be found by using `grep -r -l -P '^\t+ +[^*]'
* Removal of training whitespaces
* A few lines longer than 120 chars
Changed `--output-file` to `--output`
Default output file now has a timestamp in the name, no more overwriting
Added Section headers and file markers
Taken time is now measured and output
And some format changes were made
refs #3446