Merge branch 'linaro-android-3.10-lsk' of git://git.linaro.org/people/jstultz/android...
[firefly-linux-kernel-4.4.55.git] / tools / gator / daemon / Logging.h
1 /**
2  * Copyright (C) ARM Limited 2010-2013. 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  */
8
9 #ifndef __LOGGING_H__
10 #define __LOGGING_H__
11
12 #include <stdio.h>
13 #include <string.h>
14 #include <limits.h>
15 #ifdef WIN32
16 #include <windows.h>
17 #else
18 #include <pthread.h>
19 #endif
20
21 #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
23 class Logging {
24 public:
25         Logging(bool debug);
26         ~Logging();
27         void logError(const char* file, int line, const char* fmt, ...);
28         void logMessage(const char* fmt, ...);
29         char* getLastError() {return mErrBuf;}
30         char* getLastMessage() {return mLogBuf;}
31
32 private:
33         char    mErrBuf[4096]; // Arbitrarily large buffer to hold a string
34         char    mLogBuf[4096]; // Arbitrarily large buffer to hold a string
35         bool    mDebug;
36 #ifdef WIN32
37         HANDLE  mLoggingMutex;
38 #else
39         pthread_mutex_t mLoggingMutex;
40 #endif
41 };
42
43 extern Logging* logg;
44
45 extern void handleException() __attribute__ ((noreturn));
46
47 #endif  //__LOGGING_H__