The rationale is to separate the config.h-dependent stuff to a separate
file to eliminate the need to transitively include config.h.
+ fix the files that need config.h directly to include it
Improve MSG() in a way that LOG() is - check the log_level first and if
not printed, just skip. Previously the eventual arguments were evaluated
and also log_msg() was called (althoug exitted immediately).
Where the PACKAGE_BUGREPORT is the only used item from config.h,
use bug_msg(), which can be then removed.
Improved bug_msg() to allow printf-like fomat + arguments.
Allow the MOD_NAME to be a variable (like (constexpr const char *)). Using
non-standard extension, the standard one would be __VA_OPT__. Although
it is supported with MSVC 2019/2022, it requires the compiler flag
/Zc:preprocessor.
This version doesn't require that so use it for now. The MSVC is used to
compile the CUDA code and AJA wrapper so not to complicate the things now.
This syntax is supported for both GNU and MSVC:
1. https://stackoverflow.com/a/78185169
2. https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html
refer to GH-375
Do not crash with out_of_range exception if trying to output empty log
(`LOG(LOG_LEVEL_INFO) << "";`) - either intentionally or by mistake.
Check if output has really size >0 before comparing last char with '\n'.
Rewritten a bit, but only functional change is the above. Eg. it was
slightly counterintuitive comparing msg[msg.size() - sizeof TERM_RESET]
to '\n'. This actually caused the crash on empty string, even though
TERM_RESET was appended. It is because `sizeof TERM_RESET` counts
'\0', which is not counted in C++ string. Semantically better would
have been `strlen(TERM_RESET) - 1`, from which is obvious it will fail
if output string was originally empty.
do not prefix messages not starting on new line by timestamps, eg.:
$ uv -s embedded -t testcard -d file:n=/dev/null -V
[1698853041.393] [lavc] Stream #0:0[1698853041.393] : Video: rawvideo, 1 reference frame (UYVY / 0x59565955), uyvy422, 1920x1080 (0x0), q=2-31, 829440 kb/s[1698853041.393] , [1698853041.393] 25 tbn[1698853041.393]
Flush the output only on NL and before it store it in internal
thread-local buffer.
Locking was removed as static data are now thread-local.
this improves 808b3de3
This was unnecessary compat macro, since we always build with a compiler
that understands __attribute__ except of the AJA module in MSW, which
uses MSVC compiler
use static, not thread_local storage
This has an implications that the message is indeed printed once, even
though is called from 2 threads (this can happen eg. when printed once
during normal operation and then during module deletion, that may happen
in a different thread).
The returned value was actually incorrect (counting also formatting
escape sequences and terminating nul byte).
Since the return value should not be important for the caller, it is
perhaps better not to complicate and don't return anything.
Needs adding log_msg_once variable arguments (printf-like).
+ print always error in deinterlace - if user explicitly wants
deinterlace PP, maybe we should notify loudly
On one-shot second and further calls of one-shot message, no output was
producet, yet empty buffer was submitted to Log_output resulting in
false repeate messages:
Last message repeated <n> times
To simplify the stuff, C++ API was removed and in the C API the Logger
is taken only if actual message will be output. If someone is willing to
use the C++ API, it can be later readded (not really needed now, only
simple message are presented).
The << operator for stringstream casts the result to basic_ostream
which does not have the .str() method on some compilers. (See C++ defect
report 1023).
The previous implementation using atomics was not entirely correct,
since the following situation could happen:
1. Thread 1 detects a msg repeat
2. Thread 2 prints a message before thread 1 could print repeat notice
3. Thread 1 outputs "last msg repeated" for the msg from step 1
The stdout stream uses locking internaly anyway, so this should not have
any significant overhead. On the other hand this simplifies the code,
eliminates an allocation and fixes the leak on exit.
+ change first parameter of serialize callback to (const void *)
+ renamed "lavd-uncompressed" to "lavd-avframe" - uncompressed is vague
since there are multiple forms of uncompressed - avframe, ultragrid
pixfmt...