3 // RAII class for trace logging.
7 Copyright (C) 2006-2010, 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>
31 const char *text
, *tag
;
33 explicit Trace(const char *t
) : text(t
), tag(0)
35 osync_trace(TRACE_ENTRY
, "barry_sync: %s", text
);
38 Trace(const char *t
, const char *tag
) : text(t
), tag(tag
)
40 osync_trace(TRACE_ENTRY
, "barry_sync (%s): %s", tag
, text
);
46 osync_trace(TRACE_EXIT
, "barry_sync (%s): %s", tag
, text
);
48 osync_trace(TRACE_EXIT
, "barry_sync: %s", text
);
51 void log(const char *t
)
53 osync_trace(TRACE_INTERNAL
, "barry_sync: %s", t
);
56 void logf(const char *t
, ...)
61 int n
= vsnprintf(buffer
, sizeof(buffer
), t
, vl
);
63 if( n
> -1 && n
< (int)sizeof(buffer
) )
64 osync_trace(TRACE_INTERNAL
, "barry_sync: %s", buffer
);
66 osync_trace(TRACE_INTERNAL
, "barry_sync: (trace error, output too long for buffer: %s)", t
);