Reduce bashisms
[bcusdk.git] / eibd / libserver / trace.cpp
blob56bc914ba98162b4f9b84593ac1392cb3f3b0c95
1 /*
2 EIBD eib bus access and management daemon
3 Copyright (C) 2005-2009 Martin Koegler <mkoegler@auto.tuwien.ac.at>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
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
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include <stdio.h>
21 #include <stdarg.h>
23 #include "trace.h"
25 void
26 Trace::TracePacketUncond (int layer, void *inst, const char *msg, int Len,
27 const uchar * data)
29 int i;
30 int t = time (0);
31 printf ("Layer %d(%08X,%08X) %s(%03d):", layer, (unsigned long) inst, t,
32 msg, Len);
33 for (i = 0; i < Len; i++)
34 printf (" %02X", data[i]);
35 printf ("\n");
38 void
39 Trace::TracePrintf (int layer, void *inst, const char *msg, ...)
41 va_list ap;
42 int t = time (0);
43 printf ("Layer %d(%08X,%08X) ", layer, (unsigned long) inst, t);
44 va_start (ap, msg);
45 vprintf (msg, ap);
46 printf ("\n");
47 va_end (ap);
50 void
51 Trace::ErrorPrintfUncond (unsigned int msgid, const char *msg, ...)
53 va_list ap;
54 int t = time (0);
55 char c;
56 switch ((msgid >> 28) & 0x0f)
58 case LEVEL_FATAL:
59 c = 'F';
60 break;
61 case LEVEL_CRITICAL:
62 c = 'C';
63 break;
64 case LEVEL_ERROR:
65 c = 'E';
66 break;
67 case LEVEL_WARNING:
68 c = 'W';
69 break;
70 case LEVEL_NOTICE:
71 c = 'N';
72 break;
73 case LEVEL_INFO:
74 c = 'I';
75 break;
76 default:
77 c = '?';
79 fprintf (stderr, "%c%08d: ", c, (msgid & 0xffffff));
80 va_start (ap, msg);
81 vfprintf (stderr, msg, ap);
82 fprintf (stderr, "\n");
83 va_end (ap);