chromium/third_party/xnnpack/src/src/xnnpack/log.h

// Copyright (c) Facebook, Inc. and its affiliates.
// All rights reserved.
//
// Copyright 2019 Google LLC
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.

#pragma once

#include <inttypes.h>
#include <stdarg.h>
#include <stdlib.h>

#include "xnnpack.h"
#include "xnnpack/common.h"

#ifndef XNN_LOG_LEVEL
  #error "Undefined XNN_LOG_LEVEL"
#endif

#define XNN_LOG_NONE
#define XNN_LOG_FATAL
#define XNN_LOG_ERROR
#define XNN_LOG_WARNING
#define XNN_LOG_INFO
#define XNN_LOG_DEBUG


#ifdef __cplusplus
extern "C" {
#endif

#if XNN_LOG_LEVEL >= XNN_LOG_DEBUG
  void xnn_vlog_debug(const char* format, va_list args);
#endif

#if XNN_LOG_LEVEL >= XNN_LOG_INFO
  void xnn_vlog_info(const char* format, va_list args);
#endif

#if XNN_LOG_LEVEL >= XNN_LOG_WARNING
  void xnn_vlog_warning(const char* format, va_list args);
#endif

#if XNN_LOG_LEVEL >= XNN_LOG_ERROR
  void xnn_vlog_error(const char* format, va_list args);
#endif

#if XNN_LOG_LEVEL >= XNN_LOG_FATAL
  void xnn_vlog_fatal(const char* format, va_list args);
#endif

#if XNN_LOG_LEVEL == XNN_LOG_NONE
  inline static const char* xnn_datatype_to_string(enum xnn_datatype type) {}
#else
  const char* xnn_datatype_to_string(enum xnn_datatype type);
#endif

#ifdef __cplusplus
}  // extern "C"
#endif

#ifndef XNN_LOG_ARGUMENTS_FORMAT
  #ifdef __GNUC__
    #define XNN_LOG_ARGUMENTS_FORMAT
  #else
    #define XNN_LOG_ARGUMENTS_FORMAT
  #endif
#endif

#define xnn_log_debug(format, ...)

XNN_LOG_ARGUMENTS_FORMAT inline static void xnn_log_debug_(const char* format, ...) {}

#define xnn_log_info(format, ...)

XNN_LOG_ARGUMENTS_FORMAT inline static void xnn_log_info_(const char* format, ...) {}

#define xnn_log_warning(format, ...)

XNN_LOG_ARGUMENTS_FORMAT inline static void xnn_log_warning_(const char* format, ...) {}

#define xnn_log_error(format, ...)

XNN_LOG_ARGUMENTS_FORMAT inline static void xnn_log_error_(const char* format, ...) {}

#define xnn_log_fatal(format, ...)

XNN_LOG_ARGUMENTS_FORMAT inline static void xnn_log_fatal_(const char* format, ...) {}

#if XNN_LOG_LEVEL >= XNN_LOG_DEBUG
  #define XNN_LOG_UNREACHABLE
#else
  #define XNN_LOG_UNREACHABLE(...)
#endif