Home | History | Annotate | Line # | Download | only in include
      1 
      2 /*
      3  * Licensed Materials - Property of IBM
      4  *
      5  * trousers - An open source TCG Software Stack
      6  *
      7  * (C) Copyright International Business Machines Corp. 2004-2006
      8  *
      9  */
     10 
     11 
     12 #ifndef _TSPLOG_H_
     13 #define _TSPLOG_H_
     14 
     15 #include <stdio.h>
     16 #include <syslog.h>
     17 #include <stdlib.h>
     18 
     19 /* Debug logging */
     20 #ifdef TSS_DEBUG
     21 /* log to stdout */
     22 #define LogMessage(dest, priority, layer, fmt, ...) \
     23 	do { \
     24 		if (getenv("TSS_DEBUG_OFF") == NULL) { \
     25 			fprintf(dest, "%s %s %s:%d " fmt "\n", priority, layer, __FILE__, __LINE__, ## __VA_ARGS__); \
     26 		} \
     27 	} while (0)
     28 
     29 #define LogDebug(fmt, ...)	LogMessage(stdout, "LOG_DEBUG", APPID, fmt, ##__VA_ARGS__)
     30 #define LogDebugFn(fmt, ...)	LogMessage(stdout, "LOG_DEBUG", APPID, "%s: " fmt, __FUNCTION__, ##__VA_ARGS__)
     31 #define LogDebugData(sz,blb)	LogBlobData(APPID, sz, blb)
     32 
     33 /* Error logging */
     34 #define LogError(fmt, ...)	LogMessage(stderr, "LOG_ERR", APPID, "ERROR: " fmt, ##__VA_ARGS__)
     35 /* Warn logging */
     36 #define LogWarn(fmt, ...)	LogMessage(stdout, "LOG_WARNING", APPID, "WARNING: " fmt, ##__VA_ARGS__)
     37 /* Info Logging */
     38 #define LogInfo(fmt, ...)	LogMessage(stdout, "LOG_INFO", APPID, fmt, ##__VA_ARGS__)
     39 /* Return Value logging */
     40 extern TSS_RESULT LogTSPERR(TSS_RESULT, char *, int);
     41 #else
     42 #define LogDebug(fmt, ...)
     43 #define LogDebugFn(fmt, ...)
     44 #define LogDebugData(sz,blb)
     45 #define LogError(fmt, ...)
     46 #define LogWarn(fmt, ...)
     47 #define LogInfo(fmt, ...)
     48 #endif
     49 
     50 void LogBlobData(char *appid, unsigned long sizeOfBlob, unsigned char *blob);
     51 
     52 #endif
     53