[svn r908] added gmyth-debug functions trunk
authorrenatofilho
Thu Jan 31 19:56:16 2008 +0000 (2008-01-31)
branchtrunk
changeset 902f22ca7dadc01
parent 901 d6ec9a68363e
child 903 fe307d0f75bd
[svn r908] added gmyth-debug functions
gmyth-dbus/src/gmyth_debug.c
gmyth-dbus/src/gmyth_debug.h
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gmyth-dbus/src/gmyth_debug.c	Thu Jan 31 19:56:16 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 +}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/gmyth-dbus/src/gmyth_debug.h	Thu Jan 31 19:56:16 2008 +0000
     2.3 @@ -0,0 +1,42 @@
     2.4 +/**
     2.5 + * GMyth Library
     2.6 + *
     2.7 + * @file gmyth/gmyth_debug.h
     2.8 + * 
     2.9 + *
    2.10 + * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
    2.11 + * @author Renato Filho <renato.filho@indt.org.br>
    2.12 + *
    2.13 +* 
    2.14 +* This program is free software; you can redistribute it and/or modify
    2.15 +* it under the terms of the GNU Lesser General Public License as published by
    2.16 +* the Free Software Foundation; either version 2 of the License, or
    2.17 +* (at your option) any later version.
    2.18 +*
    2.19 +* This program is distributed in the hope that it will be useful,
    2.20 +	* but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.21 +	* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2.22 +	* GNU General Public License for more details.
    2.23 +	*
    2.24 +	* You should have received a copy of the GNU Lesser General Public License
    2.25 +	* along with this program; if not, write to the Free Software
    2.26 +	* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2.27 +	*/
    2.28 +
    2.29 +#ifndef __GMYTH_DEBUG_H__
    2.30 +#define __GMYTH_DEBUG_H__
    2.31 +
    2.32 +#include <stdarg.h>
    2.33 +#include <glib.h>
    2.34 +#include <time.h>
    2.35 +
    2.36 +G_BEGIN_DECLS
    2.37 +#define gmyth_debug(...) gmyth_debug_real (__FUNCTION__, __FILE__, __LINE__, TRUE, __VA_ARGS__)
    2.38 +void
    2.39 +gmyth_debug_real(const char *func,
    2.40 +                 const char *file, int line, gboolean newline,
    2.41 +                 const char *format, ...)
    2.42 +G_GNUC_PRINTF(5, 6);
    2.43 +
    2.44 +G_END_DECLS
    2.45 +#endif