2 * Copyright 2009, Michael Lotz, mmlr@mlotz.ch.
3 * Distributed under the terms of the MIT License.
6 #include "ATATracing.h"
13 static char sTraceBuffer
[256];
14 static uint32 sTraceBufferOffset
= 0;
18 ata_trace_printf(uint32 flags
, const char *format
, ...)
20 if (sTraceBufferOffset
< sizeof(sTraceBuffer
)) {
22 va_start(arguments
, format
);
23 size_t totalBytes
= vsnprintf(sTraceBuffer
+ sTraceBufferOffset
,
24 sizeof(sTraceBuffer
) - sTraceBufferOffset
, format
, arguments
);
25 sTraceBufferOffset
+= std::min(totalBytes
,
26 sizeof(sTraceBuffer
) - sTraceBufferOffset
- 1);
30 if (flags
& ATA_TRACE_FLUSH
) {
32 ktrace_printf(sTraceBuffer
);
34 if (flags
& ATA_TRACE_SYSLOG
)
35 dprintf(sTraceBuffer
);
37 sTraceBufferOffset
= 0;