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 17 18/* zf_logif.h: 19 * This file contains some convenience macros built on top of the ZF_LOG 20 * library, to reduce source size and improve single-line readability. 21 * 22 * ZF_LOG?_IF(condition, fmt, ...): 23 * These will call the relevant ZF_LOG?() macro if "condition" evaluates to 24 * true at runtime. 25 * 26 */ 27 28#define ZF_LOGD_IF(cond, fmt, ...) \ 29 if (cond) { ZF_LOGD("[Cond failed: %s]\n\t" fmt, #cond, ## __VA_ARGS__); } 30#define ZF_LOGI_IF(cond, fmt, ...) \ 31 if (cond) { ZF_LOGI("[Cond failed: %s]\n\t" fmt, #cond, ## __VA_ARGS__); } 32#define ZF_LOGW_IF(cond, fmt, ...) \ 33 if (cond) { ZF_LOGW("[Cond failed: %s]\n\t" fmt, #cond, ## __VA_ARGS__); } 34#define ZF_LOGE_IF(cond, fmt, ...) \ 35 if (cond) { ZF_LOGE("[Cond failed: %s]\n\t" fmt, #cond, ## __VA_ARGS__); } 36#define ZF_LOGF_IF(cond, fmt, ...) \ 37 if (cond) { ZF_LOGF("[Cond failed: %s]\n\t" fmt, #cond, ## __VA_ARGS__); } 38