gator: Version 5.18
[firefly-linux-kernel-4.4.55.git] / tools / gator / daemon / Logging.h
1 /**
2  * Copyright (C) ARM Limited 2010-2014. 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 <pthread.h>
13
14 #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"
15
16 class Logging {
17 public:
18         Logging(bool debug);
19         ~Logging();
20         void logError(const char* file, int line, const char* fmt, ...);
21         void logMessage(const char* fmt, ...);
22         char* getLastError() {return mErrBuf;}
23         char* getLastMessage() {return mLogBuf;}
24
25 private:
26         char    mErrBuf[4096]; // Arbitrarily large buffer to hold a string
27         char    mLogBuf[4096]; // Arbitrarily large buffer to hold a string
28         bool    mDebug;
29         pthread_mutex_t mLoggingMutex;
30 };
31
32 extern Logging* logg;
33
34 extern void handleException() __attribute__ ((noreturn));
35
36 #endif  //__LOGGING_H__