Multimedia API Reference

November 16, 2016 | 24.2.1 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NvLogging.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of NVIDIA CORPORATION nor the names of its
13  * contributors may be used to endorse or promote products derived
14  * from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
36 #ifndef __NV_LOGGING_H_
37 #define __NV_LOGGING_H_
38 
39 #include <iostream>
40 
56 #define LOG_LEVEL_INFO 0
57 
60 #define LOG_LEVEL_ERROR 1
61 
64 #define LOG_LEVEL_WARN 2
65 
68 #define LOG_LEVEL_DEBUG 3
69 
74 extern int log_level;
75 
79 #define DEFAULT_LOG_LEVEL LOG_LEVEL_INFO
80 
84 #define stringify(s) #s
85 #define xstringify(s) stringify(s)
86 #define __LINE_NUM_STR__ xstringify(__LINE__)
87 
104 #define PRINT_MSG(level, str) if(level <= log_level) { std::cerr << "[" #level "] (" __FILE__ ":" \
105  __LINE_NUM_STR__ ") " << str << std::endl; }
106 
110 #define INFO_MSG(str) PRINT_MSG(LOG_LEVEL_INFO, str)
111 
119 #define COMP_INFO_MSG(str) ERROR_MSG("<" << comp_name << "> " << str)
120 
128 #define CAT_INFO_MSG(str) ERROR_MSG("<" CAT_NAME "> " << str)
129 
133 #define ERROR_MSG(str) PRINT_MSG(LOG_LEVEL_ERROR, str)
134 
142 #define COMP_ERROR_MSG(str) ERROR_MSG("<" << comp_name << "> " << str)
143 
151 #define CAT_ERROR_MSG(str) ERROR_MSG("<" CAT_NAME "> " << str)
152 
157 #define SYS_ERROR_MSG(str) ERROR_MSG(str << ": " << strerror(errno))
158 
166 #define COMP_SYS_ERROR_MSG(str) SYS_ERROR_MSG("<" << comp_name << "> " << str)
167 
175 #define CAT_SYS_ERROR_MSG(str) SYS_ERROR_MSG("<" CAT_NAME "> " << str)
176 
180 #define WARN_MSG(str) PRINT_MSG(LOG_LEVEL_WARN, str)
181 
189 #define COMP_WARN_MSG(str) WARN_MSG("<" << comp_name << "> :" << str)
190 
199 #define CAT_WARN_MSG(str) WARN_MSG("<" CAT_NAME "> " << str)
200 
204 #define DEBUG_MSG(str) PRINT_MSG(LOG_LEVEL_DEBUG, str)
205 
213 #define COMP_DEBUG_MSG(str) DEBUG_MSG("<" << comp_name << "> :" << str)
214 
222 #define CAT_DEBUG_MSG(str) DEBUG_MSG("<" CAT_NAME "> " << str)
223 
224 #endif
225 
int log_level
Holds the current log level at runtime by assignment of one of the LOG_LEVEL_* values.