Commit Graph

14 Commits

Author SHA1 Message Date
Frediano Ziglio
7aa46954fd vdlog: Fix compatibility with MSVC
_wstat64 documentation states that we should include sys/types.h
and sys/stat.h.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2019-12-06 09:42:52 +00:00
Frediano Ziglio
615cd463e0 vdlog: Use _wstat64 instead of GetFileSize
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>
2019-11-21 14:48:32 +00:00
Frediano Ziglio
9ddddf205f vdlog: Use GetLocalTime instead of multiple C functions
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>
2018-07-08 20:19:21 +01:00
Frediano Ziglio
df20de186c vdlog: Factor our a "logf" function to avoid long "LOG" macro
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2018-07-08 20:19:21 +01:00
Frediano Ziglio
6a60c1dccc Make VDLog::printf static
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>
2017-07-26 15:35:01 +01:00
Frediano Ziglio
78099ae2bf log: add comment to make code clearer
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2017-07-24 16:45:38 +01:00
Frediano Ziglio
1a0bc10cbe log: rewrite log_version using config.h definitions
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>
2017-07-24 13:42:01 +01:00
Frediano Ziglio
8f47080fa8 Remove small memory leak in log_version
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>
2017-07-22 09:34:36 +01:00
Christophe Fergeau
1e543873ea vdlog: Get swprinft_s definition from vdcommon.h
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.
2013-01-22 12:43:44 +01:00
Marc-André Lureau
60e850c6e4 mingw: don't use *_s msvcrt variants
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.
2012-05-24 13:55:31 +02:00
Christophe Fergeau
df3fe9cb90 mingw: fix format string warnings
Most of them are caused by not using %lu to print a DWORD (which
is an unsigned long).
2012-02-23 19:03:25 +01:00
Arnon Gilboa
017482d779 vdlog: change log times to human readable date & time rhbz#672828
-use RHEV log format
-add log levels & macros
-remove LOG_ENABLED ifdefs
2011-11-21 14:10:55 +02:00
Arnon Gilboa
f915fa4a72 vdagent: add win7 support to service for launching agent 2009-12-23 15:31:01 +02:00
Arnon Gilboa
5ee7b5b270 fresh start 2009-11-05 13:02:54 +02:00