1/*
2 * Copyright 2017, Data61
3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4 * ABN 41 687 119 230.
5 *
6 * This software may be distributed and modified according to the terms of
7 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
8 * See "LICENSE_BSD2.txt" for details.
9 *
10 * @TAG(DATA61_BSD)
11 */
12
13#pragma once
14
15#include <utils/zf_log.h>
16#include <utils/zf_log_if.h>
17#include <sel4utils/strerror.h>
18
19/*  sel4_zf_logif.h:
20 * This file contains some convenience macros built on top of the ZF_LOG
21 * library, to reduce source size and improve single-line readability.
22 *
23 * ZF_LOG?_IF(condition, fmt, ...):
24 *  These will call the relevant ZF_LOG?() macro if "condition" evaluates to
25 *  true at runtime.
26 *
27 */
28
29#define ZF_LOGD_IFERR(err, fmt, ...) \
30	if ((err) != seL4_NoError) \
31		{ ZF_LOGD("[Err %s]:\n\t" fmt, sel4_strerror(err), ## __VA_ARGS__); }
32
33#define ZF_LOGI_IFERR(err, fmt, ...) \
34	if ((err) != seL4_NoError) \
35		{ ZF_LOGI("[Err %s]:\n\t" fmt, sel4_strerror(err), ## __VA_ARGS__); }
36
37#define ZF_LOGW_IFERR(err, fmt, ...) \
38	if ((err) != seL4_NoError) \
39		{ ZF_LOGW("[Err %s]:\n\t" fmt, sel4_strerror(err), ## __VA_ARGS__); }
40
41#define ZF_LOGE_IFERR(err, fmt, ...) \
42	if ((err) != seL4_NoError) \
43		{ ZF_LOGE("[Err %s]:\n\t" fmt, sel4_strerror(err), ## __VA_ARGS__); }
44
45#define ZF_LOGF_IFERR(err, fmt, ...) \
46	if ((err) != seL4_NoError) \
47		{ ZF_LOGF("[Err %s]:\n\t" fmt, sel4_strerror(err), ## __VA_ARGS__); }
48
49