Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2021 Arm Limited. |
| 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
| 24 | #ifndef SRC_COMMON_LOG_H |
| 25 | #define SRC_COMMON_LOG_H |
| 26 | |
| 27 | #include "arm_compute/core/Error.h" |
| 28 | #include "arm_compute/core/utils/logging/Macros.h" |
| 29 | |
| 30 | #ifdef ARM_COMPUTE_LOGGING_ENABLED |
| 31 | /** Create a logger |
| 32 | * |
| 33 | * @note It will eventually create all default loggers in don't exist |
| 34 | */ |
| 35 | #define ARM_COMPUTE_CREATE_ACL_LOGGER() \ |
| 36 | do \ |
| 37 | { \ |
| 38 | if(arm_compute::logging::LoggerRegistry::get().logger("ComputeLibrary") == nullptr) \ |
| 39 | { \ |
| 40 | arm_compute::logging::LoggerRegistry::get().create_logger("ComputeLibrary", arm_compute::logging::LogLevel::INFO); \ |
| 41 | } \ |
| 42 | } while(false) |
| 43 | #else /* ARM_COMPUTE_LOGGING_ENABLED */ |
| 44 | #define ARM_COMPUTE_CREATE_ACL_LOGGER() |
| 45 | #endif /* ARM_COMPUTE_LOGGING_ENABLED */ |
| 46 | /** Log a message to the logger |
| 47 | * |
| 48 | * @param[in] log_level Logging level |
| 49 | * @param[in] msg Message to log |
| 50 | */ |
| 51 | #define ARM_COMPUTE_LOG_MSG_ACL(log_level, msg) \ |
| 52 | do \ |
| 53 | { \ |
| 54 | ARM_COMPUTE_CREATE_ACL_LOGGER(); \ |
| 55 | ARM_COMPUTE_LOG_MSG("ComputeLibrary", log_level, msg); \ |
| 56 | } while(false) |
| 57 | /** Log a message with format to the logger |
| 58 | * |
| 59 | * @param[in] log_level Logging level |
| 60 | * @param[in] fmt String format (printf style) |
| 61 | * @param[in] ... Message arguments |
| 62 | */ |
| 63 | #define ARM_COMPUTE_LOG_MSG_WITH_FORMAT_ACL(log_level, fmt, ...) \ |
| 64 | do \ |
| 65 | { \ |
| 66 | ARM_COMPUTE_CREATE_ACL_LOGGER(); \ |
| 67 | ARM_COMPUTE_LOG_MSG_WITH_FORMAT("ComputeLibrary", log_level, fmt, __VA_ARGS__); \ |
| 68 | } while(false) |
| 69 | /** Log an error message to the logger |
| 70 | * |
| 71 | * @param[in] msg Message to log |
| 72 | */ |
| 73 | #define ARM_COMPUTE_LOG_ERROR_ACL(msg) \ |
| 74 | do \ |
| 75 | { \ |
| 76 | ARM_COMPUTE_CREATE_ACL_LOGGER(); \ |
| 77 | ARM_COMPUTE_LOG_MSG("ComputeLibrary", arm_compute::logging::LogLevel::ERROR, msg); \ |
| 78 | } while(false) |
| 79 | |
Georgios Pinitas | 3f26ef4 | 2021-02-23 10:01:33 +0000 | [diff] [blame] | 80 | /** Log an error message to the logger with function name before the message |
| 81 | * |
| 82 | * @param[in] msg Message to log |
| 83 | */ |
| 84 | #define ARM_COMPUTE_LOG_ERROR_WITH_FUNCNAME_ACL(msg) \ |
| 85 | do \ |
| 86 | { \ |
| 87 | ARM_COMPUTE_CREATE_ACL_LOGGER(); \ |
| 88 | ARM_COMPUTE_LOG_MSG_WITH_FUNCNAME("ComputeLibrary", arm_compute::logging::LogLevel::ERROR, msg); \ |
| 89 | } while(false) |
| 90 | |
Georgios Pinitas | 8a5146f | 2021-01-12 15:51:07 +0000 | [diff] [blame] | 91 | #endif /* SRC_COMMON_LOG_H */ |