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,
33 /*** file scope functions **********************************************/
36 is_logging_enabled(void)
38 static gboolean logging_initialized
= FALSE
;
39 static gboolean logging_enabled
= FALSE
;
42 if (!logging_initialized
) {
43 mc_ini
= g_strdup_printf("%s/%s", home_dir
, PROFILE_NAME
);
45 get_int(mc_ini
, "development.enable_logging", FALSE
);
47 logging_initialized
= TRUE
;
49 return logging_enabled
;
52 /*** public functions **************************************************/
55 mc_log(const char *fmt
, ...)
61 if (is_logging_enabled()) {
63 logfilename
= g_strdup_printf("%s/.mc/log", home_dir
);
64 if ((f
= fopen(logfilename
, "a")) != NULL
) {
65 (void)vfprintf(f
, fmt
, args
);