Added new function mc_always_log() for logging on early bootstrap stages
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
Этот коммит содержится в:
родитель
c8982e822c
Коммит
cf162ef810
@ -67,6 +67,28 @@ is_logging_enabled (void)
|
||||
return logging_enabled;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
mc_va_log (const char *fmt, va_list args)
|
||||
{
|
||||
FILE *f;
|
||||
char *logfilename;
|
||||
|
||||
logfilename = g_build_filename (mc_config_get_cache_path (), "mc.log", NULL);
|
||||
if (logfilename != NULL)
|
||||
{
|
||||
f = fopen (logfilename, "a");
|
||||
if (f != NULL)
|
||||
{
|
||||
(void) vfprintf (f, fmt, args);
|
||||
(void) fclose (f);
|
||||
}
|
||||
g_free (logfilename);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/*** public functions ****************************************************************************/
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -75,25 +97,25 @@ void
|
||||
mc_log (const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
FILE *f;
|
||||
char *logfilename;
|
||||
|
||||
if (is_logging_enabled ())
|
||||
{
|
||||
va_start (args, fmt);
|
||||
logfilename = g_build_filename (mc_config_get_cache_path (), "mc.log", NULL);
|
||||
if (logfilename != NULL)
|
||||
{
|
||||
f = fopen (logfilename, "a");
|
||||
if (f != NULL)
|
||||
{
|
||||
(void) vfprintf (f, fmt, args);
|
||||
(void) fclose (f);
|
||||
}
|
||||
g_free (logfilename);
|
||||
va_end (args);
|
||||
}
|
||||
}
|
||||
if (!is_logging_enabled ())
|
||||
return;
|
||||
|
||||
va_start (args, fmt);
|
||||
mc_va_log (fmt, args);
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
mc_always_log (const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start (args, fmt);
|
||||
mc_va_log (fmt, args);
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -23,6 +23,7 @@
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
extern void mc_log (const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
|
||||
extern void mc_always_log (const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user