1 // Copyright 2012 The ChromiumOS Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef GESTURES_LOGGING_H__ 6 #define GESTURES_LOGGING_H__ 7 8 #include "gestures.h" 9 10 #define Assert(condition) \ 11 do { \ 12 if (!(condition)) \ 13 Err("Assertion '" #condition "' failed"); \ 14 } while(false) 15 16 #define AssertWithReturn(condition) \ 17 do { \ 18 if (!(condition)) { \ 19 Err("Assertion '" #condition "' failed"); \ 20 return; \ 21 } \ 22 } while(false) 23 24 #define AssertWithReturnValue(condition, returnValue) \ 25 do { \ 26 if (!(condition)) { \ 27 Err("Assertion '" #condition "' failed"); \ 28 return (returnValue); \ 29 } \ 30 } while(false) 31 32 #define Log(format, ...) \ 33 gestures_log(GESTURES_LOG_INFO, "INFO:%s:%d: " format "\n", \ 34 __FILE__, __LINE__, ## __VA_ARGS__) 35 #define Err(format, ...) \ 36 gestures_log(GESTURES_LOG_ERROR, "ERROR:%s:%d: " format "\n", \ 37 __FILE__, __LINE__, ## __VA_ARGS__) 38 39 #define ErrOnce(format, ...) \ 40 do { \ 41 static bool written = false; \ 42 if (!written) { \ 43 Err(format, ## __VA_ARGS__); \ 44 written = true; \ 45 } \ 46 } while(false) 47 48 #define MTStatSample(key, value, timestamp) \ 49 gestures_log(GESTURES_LOG_INFO, "MTStat:%f:%s:%s\n", \ 50 (timestamp), (key), (value)) 51 52 #define MTStatSampleInt(key, value, timestamp) \ 53 gestures_log(GESTURES_LOG_INFO, "MTStat:%f:%s:%d\n", \ 54 (timestamp), (key), (int)(value)) 55 56 #define MTStatUpdate(key, value, timestamp) \ 57 gestures_log(GESTURES_LOG_INFO, "MTStat:%f:%s=%s\n", \ 58 (timestamp), (key), value) 59 60 #define MTStatUpdateInt(key, value, timestamp) \ 61 gestures_log(GESTURES_LOG_INFO, "MTStat:%f:%s=%d\n", \ 62 (timestamp), (key), (int)(value)) 63 64 #endif // GESTURES_LOGGING_H__ 65