gmyth-dbus/src/gmyth_debug.c
branchtrunk
changeset 925 4a8d56080089
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gmyth-dbus/src/gmyth_debug.c	Mon Feb 25 17:51:43 2008 +0000
     1.3 @@ -0,0 +1,58 @@
     1.4 +/**
     1.5 + * GMyth Library
     1.6 + *
     1.7 + * @file gmyth/gmyth_debug.c
     1.8 + * 
     1.9 + *
    1.10 + * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    1.11 + * @author Renato Filho <renato.filho@indt.org.br>
    1.12 + *
    1.13 + * 
    1.14 + * This program is free software; you can redistribute it and/or modify
    1.15 + * it under the terms of the GNU Lesser General Public License as published by
    1.16 + * the Free Software Foundation; either version 2 of the License, or
    1.17 + * (at your option) any later version.
    1.18 + *
    1.19 + * This program is distributed in the hope that it will be useful,
    1.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.22 + * GNU General Public License for more details.
    1.23 + *
    1.24 + * You should have received a copy of the GNU Lesser General Public License
    1.25 + * along with this program; if not, write to the Free Software
    1.26 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.27 + */
    1.28 +
    1.29 +#ifdef HAVE_CONFIG_H
    1.30 +#include "config.h"
    1.31 +#endif
    1.32 +
    1.33 +#include "gmyth_debug.h"
    1.34 +
    1.35 +void
    1.36 +gmyth_debug_real(const char *func,
    1.37 +                 const char *file, const int line, gboolean newline,
    1.38 +                 const char *format, ...)
    1.39 +{
    1.40 +    va_list         args;
    1.41 +    char            buffer[1025];
    1.42 +    char            str_time[255];
    1.43 +    time_t          the_time;
    1.44 +
    1.45 +
    1.46 +    if (g_getenv ("GMYTH-DEBUG"))
    1.47 +    {
    1.48 +        va_start(args, format);
    1.49 +
    1.50 +        g_vsnprintf(buffer, 1024, format, args);
    1.51 +
    1.52 +        va_end(args);
    1.53 +
    1.54 +        time(&the_time);
    1.55 +        strftime(str_time, 254, "%H:%M:%S", localtime(&the_time));
    1.56 +
    1.57 +        g_printerr(newline ? "(%s) [%p] [%s] %s:%d: %s\n" :
    1.58 +                   "(%s) [%p] [%s] %s:%d: %s", str_time, g_thread_self(), func,
    1.59 +                   file, line, buffer);
    1.60 +    }
    1.61 +}