2 Provides a log file to ease tracing the program.
4 Copyright (C) 2006 Roland Illig <roland.illig@gmx.de>.
6 This file is part of the Midnight Commander.
8 The Midnight Commander is free software; you can redistribute it
9 and/or modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version.
13 The Midnight Commander is distributed in the hope that it will be
14 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
15 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
29 #include <mhl/memory.h>
30 #include <mhl/types.h>
36 /*** file scope functions **********************************************/
39 is_logging_enabled(void)
41 static gboolean logging_initialized
= FALSE
;
42 static gboolean logging_enabled
= FALSE
;
45 if (!logging_initialized
) {
46 mc_ini
= g_strdup_printf("%s/%s", home_dir
, PROFILE_NAME
);
48 get_int(mc_ini
, "development.enable_logging", FALSE
);
50 logging_initialized
= TRUE
;
52 return logging_enabled
;
55 /*** public functions **************************************************/
58 mc_log(const char *fmt
, ...)
64 if (is_logging_enabled()) {
66 logfilename
= g_strdup_printf("%s/.mc/log", home_dir
);
67 if ((f
= fopen(logfilename
, "a")) != NULL
) {
68 (void)vfprintf(f
, fmt
, args
);