diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2012-11-25 14:36:20 +0000 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2012-11-25 14:36:20 +0000 |
commit | c3649a2def02c41d837ae1f79dda729ccb91e677 (patch) | |
tree | bea46dff212fdef977fe9094a70a939e8cc21885 /src/include/tsplog.h | |
download | trousers-upstream.tar.gz |
Imported Upstream version 0.3.9upstream/0.3.9upstream
Diffstat (limited to 'src/include/tsplog.h')
-rw-r--r-- | src/include/tsplog.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/include/tsplog.h b/src/include/tsplog.h new file mode 100644 index 0000000..bb2fa6b --- /dev/null +++ b/src/include/tsplog.h @@ -0,0 +1,52 @@ + +/* + * Licensed Materials - Property of IBM + * + * trousers - An open source TCG Software Stack + * + * (C) Copyright International Business Machines Corp. 2004-2006 + * + */ + + +#ifndef _TSPLOG_H_ +#define _TSPLOG_H_ + +#include <stdio.h> +#include <syslog.h> +#include <stdlib.h> + +/* Debug logging */ +#ifdef TSS_DEBUG +/* log to stdout */ +#define LogMessage(dest, priority, layer, fmt, ...) \ + do { \ + if (getenv("TSS_DEBUG_OFF") == NULL) { \ + fprintf(dest, "%s %s %s:%d " fmt "\n", priority, layer, __FILE__, __LINE__, ## __VA_ARGS__); \ + } \ + } while (0) + +#define LogDebug(fmt, ...) LogMessage(stdout, "LOG_DEBUG", APPID, fmt, ##__VA_ARGS__) +#define LogDebugFn(fmt, ...) LogMessage(stdout, "LOG_DEBUG", APPID, "%s: " fmt, __FUNCTION__, ##__VA_ARGS__) +#define LogDebugData(sz,blb) LogBlobData(APPID, sz, blb) + +/* Error logging */ +#define LogError(fmt, ...) LogMessage(stderr, "LOG_ERR", APPID, "ERROR: " fmt, ##__VA_ARGS__) +/* Warn logging */ +#define LogWarn(fmt, ...) LogMessage(stdout, "LOG_WARNING", APPID, "WARNING: " fmt, ##__VA_ARGS__) +/* Info Logging */ +#define LogInfo(fmt, ...) LogMessage(stdout, "LOG_INFO", APPID, fmt, ##__VA_ARGS__) +/* Return Value logging */ +extern TSS_RESULT LogTSPERR(TSS_RESULT, char *, int); +#else +#define LogDebug(fmt, ...) +#define LogDebugFn(fmt, ...) +#define LogDebugData(sz,blb) +#define LogError(fmt, ...) +#define LogWarn(fmt, ...) +#define LogInfo(fmt, ...) +#endif + +void LogBlobData(char *appid, unsigned long sizeOfBlob, unsigned char *blob); + +#endif |