* Makefile.am, logging.h, logging.c: Added a new logging module
to allow easy tracing of function calls and other events. It is only intended for debugging.
Этот коммит содержится в:
родитель
7b9f0a4f96
Коммит
e3fb94363e
@ -4,6 +4,10 @@
|
|||||||
in $(pkglibdir), to conform to the usual directory hierarchy
|
in $(pkglibdir), to conform to the usual directory hierarchy
|
||||||
standards. Fixes #2796.
|
standards. Fixes #2796.
|
||||||
|
|
||||||
|
* Makefile.am, logging.h, logging.c: Added a new logging module
|
||||||
|
to allow easy tracing of function calls and other events. It is
|
||||||
|
only intended for debugging.
|
||||||
|
|
||||||
2006-01-24 Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
|
2006-01-24 Jindrich Makovicka <makovick@kmlinux.fjfi.cvut.cz>
|
||||||
|
|
||||||
* file.c (copy_file_file): In 'Reget' mode take into account
|
* file.c (copy_file_file): In 'Reget' mode take into account
|
||||||
|
@ -52,7 +52,9 @@ SRCS = achown.c achown.h background.c background.h boxes.c boxes.h \
|
|||||||
find.h findme.c findme.h fs.h \
|
find.h findme.c findme.h fs.h \
|
||||||
glibcompat.c glibcompat.h global.h help.c help.h hotlist.c \
|
glibcompat.c glibcompat.h global.h help.c help.h hotlist.c \
|
||||||
hotlist.h info.c info.h key.c key.h keyxdef.c layout.c \
|
hotlist.h info.c info.h key.c key.h keyxdef.c layout.c \
|
||||||
layout.h learn.c learn.h listmode.c listmode.h main.c main.h \
|
layout.h learn.c learn.h listmode.c listmode.h \
|
||||||
|
logging.h logging.c \
|
||||||
|
main.c main.h \
|
||||||
menu.c menu.h mountlist.c mountlist.h mouse.c mouse.h myslang.h \
|
menu.c menu.h mountlist.c mountlist.h mouse.c mouse.h myslang.h \
|
||||||
option.c option.h panel.h panelize.c panelize.h poptalloca.h \
|
option.c option.h panel.h panelize.c panelize.h poptalloca.h \
|
||||||
popt.c poptconfig.c popt.h popthelp.c poptint.h poptparse.c \
|
popt.c poptconfig.c popt.h popthelp.c poptint.h poptparse.c \
|
||||||
|
65
src/logging.c
Обычный файл
65
src/logging.c
Обычный файл
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
Provides a log file to ease tracing the program.
|
||||||
|
|
||||||
|
Copyright (C) 2005 Roland Illig <roland.illig@gmx.de>.
|
||||||
|
|
||||||
|
This file is part of the Midnight Commander.
|
||||||
|
|
||||||
|
The Midnight Commander is free software; you can redistribute it
|
||||||
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The Midnight Commander is distributed in the hope that it will be
|
||||||
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||||
|
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "global.h"
|
||||||
|
#include "logging.h"
|
||||||
|
#include "setup.h"
|
||||||
|
|
||||||
|
/*** file scope functions **********************************************/
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
logging_enabled(void)
|
||||||
|
{
|
||||||
|
char *mc_ini;
|
||||||
|
gboolean retval;
|
||||||
|
|
||||||
|
mc_ini = g_strdup_printf("%s/%s", home_dir, PROFILE_NAME);
|
||||||
|
retval = get_int(mc_ini, "development.enable_logging", FALSE);
|
||||||
|
g_free(mc_ini);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*** public functions **************************************************/
|
||||||
|
|
||||||
|
void
|
||||||
|
mc_log(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
FILE *f;
|
||||||
|
char *logfilename;
|
||||||
|
|
||||||
|
if (logging_enabled) {
|
||||||
|
va_start(args, fmt);
|
||||||
|
logfilename = g_strdup_printf("%s/.mc/log", home_dir);
|
||||||
|
if ((f = fopen(logfilename, "a")) != NULL) {
|
||||||
|
(void)vfprintf(f, fmt, args);
|
||||||
|
(void)fclose(f);
|
||||||
|
}
|
||||||
|
g_free(logfilename);
|
||||||
|
}
|
||||||
|
}
|
12
src/logging.h
Обычный файл
12
src/logging.h
Обычный файл
@ -0,0 +1,12 @@
|
|||||||
|
#ifndef MC_LOGGING_H
|
||||||
|
#define MC_LOGGING_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
This file provides an easy-to-use function for writing all kinds of
|
||||||
|
events into a central log file that can be used for debugging.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern void mc_log(const char *, ...)
|
||||||
|
__attribute__((__format__(__printf__,1,2)));
|
||||||
|
|
||||||
|
#endif
|
Загрузка…
x
Ссылка в новой задаче
Block a user