2 Provides a log file to ease tracing the program.
4 Copyright (C) 2006, 2009 Free Software Foundation, Inc.
6 Written: 2006 Roland Illig <roland.illig@gmx.de>.
8 This file is part of the Midnight Commander.
10 The Midnight Commander is free software; you can redistribute it
11 and/or modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2 of the
13 License, or (at your option) any later version.
15 The Midnight Commander is distributed in the hope that it will be
16 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
17 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
27 * \brief Source: provides a log file to ease tracing the program
35 #include "lib/global.h"
37 #include "lib/mcconfig.h"
38 #include "lib/fileloc.h"
40 #include "src/setup.h"
43 /*** global variables ****************************************************************************/
45 /*** file scope macro definitions ****************************************************************/
47 /*** file scope type declarations ****************************************************************/
49 /*** file scope variables ************************************************************************/
51 /*** file scope functions ************************************************************************/
52 /* --------------------------------------------------------------------------------------------- */
55 is_logging_enabled (void)
57 static gboolean logging_initialized
= FALSE
;
58 static gboolean logging_enabled
= FALSE
;
60 if (!logging_initialized
)
62 logging_enabled
= mc_config_get_bool (mc_main_config
,
63 CONFIG_APP_SECTION
, "development.enable_logging",
65 logging_initialized
= TRUE
;
67 return logging_enabled
;
70 /* --------------------------------------------------------------------------------------------- */
71 /*** public functions ****************************************************************************/
72 /* --------------------------------------------------------------------------------------------- */
75 mc_log (const char *fmt
, ...)
81 if (is_logging_enabled ())
84 logfilename
= g_strdup_printf ("%s/%s/log", home_dir
, MC_USERCONF_DIR
);
85 if (logfilename
!= NULL
)
87 f
= fopen (logfilename
, "a");
90 (void) vfprintf (f
, fmt
, args
);
99 /* --------------------------------------------------------------------------------------------- */