1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/camera/CameraCommon.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,64 @@ 1.4 +/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ 1.5 +/* vim: set ts=2 et sw=2 tw=40: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef DOM_CAMERA_CAMERACOMMON_H 1.11 +#define DOM_CAMERA_CAMERACOMMON_H 1.12 + 1.13 +#ifndef __func__ 1.14 +#ifdef __FUNCTION__ 1.15 +#define __func__ __FUNCTION__ 1.16 +#else 1.17 +#define __func__ __FILE__ 1.18 +#endif 1.19 +#endif 1.20 + 1.21 +#ifndef NAN 1.22 +#define NAN std::numeric_limits<double>::quiet_NaN() 1.23 +#endif 1.24 + 1.25 +#include "prlog.h" 1.26 + 1.27 +#ifdef PR_LOGGING 1.28 +extern PRLogModuleInfo* GetCameraLog(); 1.29 +#define DOM_CAMERA_LOG( type, ... ) PR_LOG(GetCameraLog(), (PRLogModuleLevel)type, ( __VA_ARGS__ )) 1.30 +#else 1.31 +#define DOM_CAMERA_LOG( type, ... ) 1.32 +#endif 1.33 + 1.34 +#define DOM_CAMERA_LOGA( ... ) DOM_CAMERA_LOG( 0, __VA_ARGS__ ) 1.35 + 1.36 +/** 1.37 + * From the least to the most output. 1.38 + */ 1.39 +enum { 1.40 + DOM_CAMERA_LOG_NOTHING, 1.41 + DOM_CAMERA_LOG_ERROR, 1.42 + DOM_CAMERA_LOG_WARNING, 1.43 + DOM_CAMERA_LOG_INFO, 1.44 + DOM_CAMERA_LOG_TRACE, 1.45 + DOM_CAMERA_LOG_REFERENCES 1.46 +}; 1.47 + 1.48 +/** 1.49 + * DOM_CAMERA_LOGR() can be called before 'gCameraLog' is set, so 1.50 + * we need to handle this one a little differently. 1.51 + */ 1.52 +#ifdef PR_LOGGING 1.53 +#define DOM_CAMERA_LOGR( ... ) \ 1.54 + do { \ 1.55 + if (GetCameraLog()) { \ 1.56 + DOM_CAMERA_LOG( DOM_CAMERA_LOG_REFERENCES, __VA_ARGS__ ); \ 1.57 + } \ 1.58 + } while (0) 1.59 +#else 1.60 +#define DOM_CAMERA_LOGR( ... ) 1.61 +#endif 1.62 +#define DOM_CAMERA_LOGT( ... ) DOM_CAMERA_LOG( DOM_CAMERA_LOG_TRACE, __VA_ARGS__ ) 1.63 +#define DOM_CAMERA_LOGI( ... ) DOM_CAMERA_LOG( DOM_CAMERA_LOG_INFO, __VA_ARGS__ ) 1.64 +#define DOM_CAMERA_LOGW( ... ) DOM_CAMERA_LOG( DOM_CAMERA_LOG_WARNING, __VA_ARGS__ ) 1.65 +#define DOM_CAMERA_LOGE( ... ) DOM_CAMERA_LOG( DOM_CAMERA_LOG_ERROR, __VA_ARGS__ ) 1.66 + 1.67 +#endif // DOM_CAMERA_CAMERACOMMON_H