gmyth-dbus/src/gmyth_debug.c
author renatofilho
Thu Jan 31 19:56:16 2008 +0000 (2008-01-31)
branchtrunk
changeset 902 f22ca7dadc01
permissions -rw-r--r--
[svn r908] added gmyth-debug functions
     1 /**
     2  * GMyth Library
     3  *
     4  * @file gmyth/gmyth_debug.c
     5  * 
     6  *
     7  * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
     8  * @author Renato Filho <renato.filho@indt.org.br>
     9  *
    10  * 
    11  * This program is free software; you can redistribute it and/or modify
    12  * it under the terms of the GNU Lesser General Public License as published by
    13  * the Free Software Foundation; either version 2 of the License, or
    14  * (at your option) any later version.
    15  *
    16  * This program is distributed in the hope that it will be useful,
    17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19  * GNU General Public License for more details.
    20  *
    21  * You should have received a copy of the GNU Lesser General Public License
    22  * along with this program; if not, write to the Free Software
    23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    24  */
    25 
    26 #ifdef HAVE_CONFIG_H
    27 #include "config.h"
    28 #endif
    29 
    30 #include "gmyth_debug.h"
    31 
    32 void
    33 gmyth_debug_real(const char *func,
    34                  const char *file, const int line, gboolean newline,
    35                  const char *format, ...)
    36 {
    37     va_list         args;
    38     char            buffer[1025];
    39     char            str_time[255];
    40     time_t          the_time;
    41 
    42 
    43     if (g_getenv ("GMYTH-DEBUG"))
    44     {
    45         va_start(args, format);
    46 
    47         g_vsnprintf(buffer, 1024, format, args);
    48 
    49         va_end(args);
    50 
    51         time(&the_time);
    52         strftime(str_time, 254, "%H:%M:%S", localtime(&the_time));
    53 
    54         g_printerr(newline ? "(%s) [%p] [%s] %s:%d: %s\n" :
    55                    "(%s) [%p] [%s] %s:%d: %s", str_time, g_thread_self(), func,
    56                    file, line, buffer);
    57     }
    58 }