blob: a7b45239f5d81f357b783d0b97b337030c12481a [file] [log] [blame]
Jon Medhurstaaf37a32013-06-11 12:10:56 +01001/**
Jon Medhurstb1d07442015-05-08 12:04:18 +01002 * Copyright (C) ARM Limited 2010-2015. All rights reserved.
Jon Medhurstaaf37a32013-06-11 12:10:56 +01003 *
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
Jon Medhurst96b56152014-10-30 18:01:15 +00009#ifndef __LOGGING_H__
10#define __LOGGING_H__
Jon Medhurstaaf37a32013-06-11 12:10:56 +010011
Jon Medhurstaaf37a32013-06-11 12:10:56 +010012#include <pthread.h>
Jon Medhurstaaf37a32013-06-11 12:10:56 +010013
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
16class Logging {
17public:
18 Logging(bool debug);
19 ~Logging();
Jon Medhurstb1d07442015-05-08 12:04:18 +010020#define logError(...) _logError(__func__, __FILE__, __LINE__, __VA_ARGS__)
21 __attribute__ ((format (printf, 5, 6)))
22 void _logError(const char *function, const char *file, int line, const char *fmt, ...);
23#define logMessage(...) _logMessage(__func__, __FILE__, __LINE__, __VA_ARGS__)
24 __attribute__ ((format (printf, 5, 6)))
25 void _logMessage(const char *function, const char *file, int line, const char *fmt, ...);
26 char *getLastError() {return mErrBuf;}
27 char *getLastMessage() {return mLogBuf;}
Jon Medhurstaaf37a32013-06-11 12:10:56 +010028
29private:
Jon Medhurst96b56152014-10-30 18:01:15 +000030 char mErrBuf[4096]; // Arbitrarily large buffer to hold a string
31 char mLogBuf[4096]; // Arbitrarily large buffer to hold a string
32 bool mDebug;
33 pthread_mutex_t mLoggingMutex;
Jon Medhurstaaf37a32013-06-11 12:10:56 +010034};
35
Jon Medhurstb1d07442015-05-08 12:04:18 +010036extern Logging *logg;
Jon Medhurstaaf37a32013-06-11 12:10:56 +010037
38extern void handleException() __attribute__ ((noreturn));
39
Jon Medhurste31266f2014-08-04 15:47:44 +010040#endif //__LOGGING_H__