This has different advantages:
- code is shorter and more readable;
- does not need to open the file and close;
- works on files bigger than 4gb.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
The GetLocalTime function already returns all information we
need for the log, no needs to call multiple C functions.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
VDLog::printf is called only using a VDLog pointer.
Since this class is a singleton, there can only be one instance of it,
so LOG() does not really need to deal with it, VDLog::printf can
do that instead.
This simplifies LOG macros by not having to choose between printf and
VDLog::printf.
The manual GNU __attribute__ is used as the format to use is
not the standard __printf__ format used in SPICE_GNUC_PRINTF
but you need to use the gnu_printf format. For instance the "%llu"
syntax is accepted by gnu_print format but not by __printf__ one.
MinGW C++ by default uses gnu_printf format for all formatting
functions.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
Instead of having to get the version information from the
executable resources get from the build configuration file.
The same version is used to build the version information
resource.
This also remove a bug in log_version where "throw" statements
were used to raise again a not existing exception on case
of failures.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
log_version() declares 2 info_buf variables, the inner one is used to
hold allocated memory, but then we free the outer one, which is NULL.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
vdlog.cpp has an #ifdef check for OLDMSVC to choose between using
swprintf or swprintf_s. Since vdcommon.h provides a compat #define
for swprintf_s when OLDMSVC is set, it's better to use this one.
Apparently, it comes with a recent version of C library (msvcrt90?),
but I don't know if we can/should ship also a MS dll. Probably it used
to work with an inlined version with VS headers.
The build can be tweaked to use the -non-_s variant with -DOLDMSVCRT
CFLAGS.