summaryrefslogtreecommitdiff
path: root/navit/support/espeak/debug.c
blob: 38ea57c99361f2cbf33ec039b522818d0da76cbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <stdio.h>
#include <stdarg.h>
#include "speech.h"
#include "debug.h"

#ifdef DEBUG_ENABLED
#include <sys/time.h>
#include <unistd.h>

static FILE* fd_log=NULL;
static const char* FILENAME="/tmp/espeak.log";

void debug_init()
{
	if((fd_log = fopen(FILENAME,"a")) != NULL)
		setvbuf(fd_log, NULL, _IONBF, 0);
}

void debug_enter(const char* text)
{
  struct timeval tv;

  gettimeofday(&tv, NULL);                  

  //  fd_log = fopen(FILENAME,"a");
  if (!fd_log)
    {
      debug_init();
    }

  if (fd_log)
    {
      fprintf(fd_log, "%03d.%03dms > ENTER %s\n",(int)(tv.tv_sec%1000), (int)(tv.tv_usec/1000), text);
      //      fclose(fd_log);
    }
}


void debug_show(const char *format, ...)
{
  va_list args;		
  va_start(args, format);
  //  fd_log = fopen(FILENAME,"a");
  if (!fd_log)
    {
      debug_init();
    }
  if (fd_log)
    {
      vfprintf(fd_log, format, args);
      //      fclose(fd_log);
    }  
  va_end(args);
}

void debug_time(const char* text)
{
  struct timeval tv;

  gettimeofday(&tv, NULL);                  

  //  fd_log = fopen(FILENAME,"a");
  if (!fd_log)
    {
      debug_init();
    }
  if (fd_log)
    {
      fprintf(fd_log, "%03d.%03dms > %s\n",(int)(tv.tv_sec%1000), (int)(tv.tv_usec/1000), text);
      //      fclose(fd_log);
    }
}

#endif