loudmouth/inc/lm-debug.h
changeset 10 59927b2d3b75
parent 0 d0f3a028347a
equal deleted inserted replaced
0:d0f3a028347a 10:59927b2d3b75
     1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
       
     2 /*
       
     3  * Copyright (C) 2003 Imendio AB
       
     4  *
       
     5  * This program is free software; you can redistribute it and/or
       
     6  * modify it under the terms of the GNU Lesser General Public License as
       
     7  * published by the Free Software Foundation; either version 2 of the
       
     8  * License, or (at your option) any later version.
       
     9  *
       
    10  * This program is distributed in the hope that it will be useful,
       
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    13  * Lesser General Public License for more details.
       
    14  *
       
    15  * You should have received a copy of the GNU Lesser General Public
       
    16  * License along with this program; if not, write to the
       
    17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
       
    18  * Boston, MA 02111-1307, USA.
       
    19  */
       
    20 
       
    21 #ifndef __LM_DEBUG_H__
       
    22 #define __LM_DEBUG_H__
       
    23 #include <stdio.h>
       
    24 #include <glib.h>
       
    25 #include "lm_enums.h"
       
    26 
       
    27 //Wsd changes
       
    28 
       
    29 /*typedef enum {
       
    30 
       
    31 	LM_LOG_LEVEL_VERBOSE = 1 << (G_LOG_LEVEL_USER_SHIFT),
       
    32 	LM_LOG_LEVEL_NET     = 1 << (G_LOG_LEVEL_USER_SHIFT + 1),
       
    33 	LM_LOG_LEVEL_PARSER  = 1 << (G_LOG_LEVEL_USER_SHIFT + 2),
       
    34 	LM_LOG_LEVEL_SSL     = 1 << (G_LOG_LEVEL_USER_SHIFT + 3),
       
    35 	LM_LOG_LEVEL_SASL    = 1 << (G_LOG_LEVEL_USER_SHIFT + 4),
       
    36 	LM_LOG_LEVEL_ALL     = (LM_LOG_LEVEL_NET |
       
    37 				LM_LOG_LEVEL_VERBOSE |
       
    38 				LM_LOG_LEVEL_PARSER |
       
    39 				LM_LOG_LEVEL_SSL |
       
    40 				LM_LOG_LEVEL_SASL)
       
    41 } LmLogLevelFlags;
       
    42 */
       
    43 #ifndef LM_LOG_DOMAIN
       
    44 #  define LM_LOG_DOMAIN "LM"
       
    45 #endif
       
    46 
       
    47 #ifndef _DEBUG
       
    48 #define LM_NO_DEBUG
       
    49 #endif
       
    50 #ifdef G_HAVE_ISO_VARARGS
       
    51 #  ifdef LM_NO_DEBUG
       
    52 #    define lm_verbose(...)
       
    53 #  else
       
    54 #    define lm_verbose(...) \
       
    55        g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_VERBOSE, __VA_ARGS__)
       
    56 #  endif
       
    57 #elif defined(G_HAVE_GNUC_VARARGS)
       
    58 #  if LM_NO_DEBUG
       
    59 #    define lm_verbose(fmt...)
       
    60 #  else
       
    61 #    define lm_verbose(fmt...) \
       
    62        g_log (LM_LOG_DOMAIN, LM_LOG_LEVEL_VERBOSE, fmt)
       
    63 #  endif
       
    64 #else
       
    65 #  ifdef LM_NO_DEBUG
       
    66   static void
       
    67  lm_verbose(const gchar *format, ...) {};
       
    68 #  else
       
    69 static void
       
    70 lm_verbose (const gchar *format, ...)
       
    71 {
       
    72 //#ifdef HAVELMLOGS
       
    73 	FILE *fp;
       
    74   va_list args;
       
    75   va_start (args, format);
       
    76  // g_logv (LM_LOG_DOMAIN, LM_LOG_LEVEL_VERBOSE, format, args);
       
    77 	fp = fopen("c:\\lmlogs.txt","a");
       
    78 
       
    79 	if(fp)
       
    80 		{
       
    81 	/*			fprintf(fp,arg);
       
    82 		fprintf(fp,"\n");*/
       
    83 	//	fprintf (fp, "%lu: 0x%lx: ", _dbus_getpid (), pthread_self ());
       
    84 		vfprintf (fp, format, args);
       
    85 		fflush(fp);
       
    86 		fclose(fp);
       
    87 		}
       
    88   va_end (args);
       
    89   //#endif
       
    90 }
       
    91 #  endif
       
    92 #endif
       
    93 
       
    94 void lm_debug_init (void);
       
    95 
       
    96 #endif /* __LM_DEBUG_H__ */
       
    97 #define UNUSED_FORMAL_PARAM(p) (void) p
       
    98