1 /**
2 * Copyright (C) ARM Limited 2010-2011. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
9 #ifndef __LOGGING_H__
10 #define __LOGGING_H__
12 #ifdef WIN32
13 #include <windows.h>
14 #else
15 #include <pthread.h>
16 #endif
17 #include <stdio.h>
18 #include <string.h>
20 #define DRIVER_ERROR "\n Driver issue:\n >> gator.ko must be built against the current kernel version & configuration\n >> gator.ko should be co-located with gatord in the same directory\n >> OR insmod gator.ko prior to launching gatord"
22 class Logging {
23 public:
24 Logging(bool debug);
25 ~Logging();
26 void logError(const char* file, int line, const char* fmt, ...);
27 void logMessage(const char* fmt, ...);
28 void SetWarningFile(char* path) {strncpy(mWarningXMLPath, path, sizeof(mWarningXMLPath) - 1);}
29 char* getLastError() {return mErrBuf;}
30 char* getLastMessage() {return mLogBuf;}
32 private:
33 char mWarningXMLPath[4096];
34 char mErrBuf[4096];
35 char mLogBuf[4096];
36 bool mDebug;
37 bool mFileCreated;
38 #ifdef WIN32
39 HANDLE mLoggingMutex;
40 #else
41 pthread_mutex_t mLoggingMutex;
42 #endif
43 };
45 extern Logging* logg;
47 #endif //__LOGGING_H__