1706f2543Smrg/*
2706f2543Smrg * Xephyr - A kdrive X server thats runs in a host X window.
3706f2543Smrg *          Authored by Matthew Allum <mallum@openedhand.com>
4706f2543Smrg *
5706f2543Smrg * Copyright © 2007 OpenedHand Ltd
6706f2543Smrg *
7706f2543Smrg * Permission to use, copy, modify, distribute, and sell this software and its
8706f2543Smrg * documentation for any purpose is hereby granted without fee, provided that
9706f2543Smrg * the above copyright notice appear in all copies and that both that
10706f2543Smrg * copyright notice and this permission notice appear in supporting
11706f2543Smrg * documentation, and that the name of OpenedHand Ltd not be used in
12706f2543Smrg * advertising or publicity pertaining to distribution of the software without
13706f2543Smrg * specific, written prior permission. OpenedHand Ltd makes no
14706f2543Smrg * representations about the suitability of this software for any purpose.  It
15706f2543Smrg * is provided "as is" without express or implied warranty.
16706f2543Smrg *
17706f2543Smrg * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
18706f2543Smrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
19706f2543Smrg * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
20706f2543Smrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21706f2543Smrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
22706f2543Smrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23706f2543Smrg * PERFORMANCE OF THIS SOFTWARE.
24706f2543Smrg *
25706f2543Smrg * Authors:
26706f2543Smrg *    Dodji Seketeli <dodji@openedhand.com>
27706f2543Smrg */
28706f2543Smrg#ifndef __EPHYRLOG_H__
29706f2543Smrg#define __EPHYRLOG_H__
30706f2543Smrg
31706f2543Smrg#include <assert.h>
32706f2543Smrg#include "os.h"
33706f2543Smrg
34706f2543Smrg#ifndef DEBUG
35706f2543Smrg/*we are not in debug mode*/
36706f2543Smrg#define EPHYR_LOG(...)
37706f2543Smrg#define EPHYR_LOG_ERROR(...)
38706f2543Smrg#endif /*!DEBUG*/
39706f2543Smrg
40706f2543Smrg#define ERROR_LOG_LEVEL 3
41706f2543Smrg#define INFO_LOG_LEVEL 4
42706f2543Smrg
43706f2543Smrg#ifndef EPHYR_LOG
44706f2543Smrg#define EPHYR_LOG(...) \
45706f2543SmrgLogMessageVerb(X_NOTICE, INFO_LOG_LEVEL, "in %s:%d:%s: ",\
46706f2543Smrg                      __FILE__, __LINE__, __func__) ; \
47706f2543SmrgLogMessageVerb(X_NOTICE, INFO_LOG_LEVEL, __VA_ARGS__)
48706f2543Smrg#endif /*nomadik_log*/
49706f2543Smrg
50706f2543Smrg#ifndef EPHYR_LOG_ERROR
51706f2543Smrg#define EPHYR_LOG_ERROR(...) \
52706f2543SmrgLogMessageVerb(X_NOTICE, ERROR_LOG_LEVEL, "Error:in %s:%d:%s: ",\
53706f2543Smrg                      __FILE__, __LINE__, __func__) ; \
54706f2543SmrgLogMessageVerb(X_NOTICE, ERROR_LOG_LEVEL, __VA_ARGS__)
55706f2543Smrg#endif /*EPHYR_LOG_ERROR*/
56706f2543Smrg
57706f2543Smrg#ifndef EPHYR_RETURN_IF_FAIL
58706f2543Smrg#define EPHYR_RETURN_IF_FAIL(cond) \
59706f2543Smrgif (!(cond)) {EPHYR_LOG_ERROR("condition %s failed\n", #cond);return;}
60706f2543Smrg#endif /*nomadik_return_if_fail*/
61706f2543Smrg
62706f2543Smrg#ifndef EPHYR_RETURN_VAL_IF_FAIL
63706f2543Smrg#define EPHYR_RETURN_VAL_IF_FAIL(cond,val) \
64706f2543Smrgif (!(cond)) {EPHYR_LOG_ERROR("condition %s failed\n", #cond);return val;}
65706f2543Smrg#endif /*nomadik_return_val_if_fail*/
66706f2543Smrg
67706f2543Smrg#endif /*__EPHYRLOG_H__*/
68