BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / kernel / drivers / audio / ac97 / es1370 / debug.c
blobdcc715c7c7ab9c31885363d91cd981c3865027c2
1 /*
2 * ES1370 Haiku Driver for ES1370 audio
4 * Copyright 2002-2007, Haiku, Inc.
5 * Distributed under the terms of the MIT License.
7 * Authors:
8 * Marcus Overhagen, marcus@overhagen.de
9 * Jerome Duval, jerome.duval@free.fr
13 #include <KernelExport.h>
15 #include <stdio.h>
16 #include <string.h>
17 #include <fcntl.h>
18 #include <unistd.h>
20 #include <directories.h>
21 #include <OS.h>
23 #include "debug.h"
24 #include "es1370.h"
27 #if DEBUG > 0
28 static const char *logfile = kSystemLogDirectory "/es1370.log";
29 static sem_id loglock;
30 #endif
33 void debug_printf(const char *text,...);
34 void log_printf(const char *text,...);
35 void log_create(void);
38 void debug_printf(const char *text,...)
40 char buf[1024];
41 va_list ap;
43 va_start(ap,text);
44 vsprintf(buf,text,ap);
45 va_end(ap);
47 dprintf(DRIVER_NAME ": %s",buf);
51 void log_create()
53 #if DEBUG > 0
54 int fd = open(logfile, O_WRONLY | O_CREAT | O_TRUNC, 0666);
55 const char *text = DRIVER_NAME ", " VERSION "\n";
56 loglock = create_sem(1,"logfile sem");
57 write(fd,text,strlen(text));
58 close(fd);
59 #endif
63 void log_printf(const char *text,...)
65 #if DEBUG > 0
66 int fd;
67 char buf[1024];
68 va_list ap;
70 va_start(ap,text);
71 vsprintf(buf,text,ap);
72 va_end(ap);
74 dprintf(DRIVER_NAME ": %s",buf);
76 acquire_sem(loglock);
77 fd = open(logfile, O_WRONLY | O_APPEND);
78 write(fd,buf,strlen(buf));
79 close(fd);
80 release_sem(loglock);
82 #if DEBUG > 1
83 snooze(150000);
84 #endif
85 #endif