3 // RAII class for trace logging.
7 Copyright (C) 2006-2009, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #ifndef __BARRY_SYNC_TRACE_H__
23 #define __BARRY_SYNC_TRACE_H__
25 #include <opensync/opensync.h>
30 const char *text
, *tag
;
32 explicit Trace(const char *t
) : text(t
), tag(0)
34 osync_trace(TRACE_ENTRY
, "barry_sync: %s", text
);
37 Trace(const char *t
, const char *tag
) : text(t
), tag(tag
)
39 osync_trace(TRACE_ENTRY
, "barry_sync (%s): %s", tag
, text
);
45 osync_trace(TRACE_EXIT
, "barry_sync (%s): %s", tag
, text
);
47 osync_trace(TRACE_EXIT
, "barry_sync: %s", text
);
50 void log(const char *t
)
52 osync_trace(TRACE_INTERNAL
, "barry_sync: %s", t
);
55 void logf(const char *t
, ...)
60 int n
= vsnprintf(buffer
, sizeof(buffer
), t
, vl
);
62 if( n
> -1 && n
< (int)sizeof(buffer
) )
63 osync_trace(TRACE_INTERNAL
, "barry_sync: %s", buffer
);
65 osync_trace(TRACE_INTERNAL
, "barry_sync: (trace error, output too long for buffer: %s)", t
);