[svn r133] implemented debug function trunk
authorrenatofilho
Tue Nov 28 21:05:25 2006 +0000 (2006-11-28)
branchtrunk
changeset 132c8fd7abae511
parent 131 d1ae310096bd
child 133 ce8246fe60a2
[svn r133] implemented debug function
gmyth/src/gmyth_debug.c
gmyth/src/gmyth_debug.h
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gmyth/src/gmyth_debug.c	Tue Nov 28 21:05:25 2006 +0000
     1.3 @@ -0,0 +1,52 @@
     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 + * 
    1.15 + * This program is free software; you can redistribute it and/or modify
    1.16 + * it under the terms of the GNU Lesser General Public License as published by
    1.17 + * the Free Software Foundation; either version 2 of the License, or
    1.18 + * (at your option) any later version.
    1.19 + *
    1.20 + * This program is distributed in the hope that it will be useful,
    1.21 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.22 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.23 + * GNU General Public License for more details.
    1.24 + *
    1.25 + * You should have received a copy of the GNU Lesser General Public License
    1.26 + * along with this program; if not, write to the Free Software
    1.27 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.28 + */
    1.29 +
    1.30 +#include "gmyth_debug.h"
    1.31 +
    1.32 +void
    1.33 +gmyth_debug_real (const char *func,
    1.34 +                  const char *file,
    1.35 +                  const int line,
    1.36 +                  gboolean newline,
    1.37 +                  const char *format, ...)
    1.38 +{
    1.39 +    va_list args;
    1.40 +    char buffer[1025];
    1.41 +    char str_time[255];
    1.42 +    time_t the_time;
    1.43 +
    1.44 +    va_start (args, format);
    1.45 +
    1.46 +    g_vsnprintf (buffer, 1024, format, args);
    1.47 +
    1.48 +    va_end (args);
    1.49 +
    1.50 +    time (&the_time);
    1.51 +    strftime (str_time, 254, "%H:%M:%S", localtime (&the_time));
    1.52 +
    1.53 +    g_printerr (newline ? "(%s) [%p] [%s] %s:%d: %s\n" : "(%s) [%p] [%s] %s:%d: %s",
    1.54 +            str_time, g_thread_self (), func, file, line, buffer);
    1.55 +}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/gmyth/src/gmyth_debug.h	Tue Nov 28 21:05:25 2006 +0000
     2.3 @@ -0,0 +1,48 @@
     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 + * 
    2.15 + * This program is free software; you can redistribute it and/or modify
    2.16 + * it under the terms of the GNU Lesser General Public License as published by
    2.17 + * the Free Software Foundation; either version 2 of the License, or
    2.18 + * (at your option) any later version.
    2.19 + *
    2.20 + * This program is distributed in the hope that it will be useful,
    2.21 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.22 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2.23 + * GNU General Public License for more details.
    2.24 + *
    2.25 + * You should have received a copy of the GNU Lesser General Public License
    2.26 + * along with this program; if not, write to the Free Software
    2.27 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2.28 + */
    2.29 +
    2.30 +#ifndef __GMYTH_DEBUG_H__
    2.31 +#define __GMYTH_DEBUG_H__
    2.32 +
    2.33 +#include <stdarg.h>
    2.34 +#include <glib.h>
    2.35 +
    2.36 +G_BEGIN_DECLS
    2.37 +
    2.38 +#ifdef GMYTH_USE_DEBUG
    2.39 +#define gmyth_debug(...) gmyth_debug_real (__FUNCTION__, __FILE__, __LINE__, TRUE, __VA_ARGS__)
    2.40 +#else
    2.41 +#define gmyth_debug(...)
    2.42 +#endif
    2.43 +
    2.44 +void gmyth_debug_real (const char *func,
    2.45 +                       const char *file,
    2.46 +                       int line,
    2.47 +                       gboolean newline,
    2.48 +                       const char *format, ...) G_GNUC_PRINTF (5, 6);
    2.49 +
    2.50 +G_END_DECLS
    2.51 +#endif