DriveWorks SDK Reference
3.0.4260 Release
For Test and Development only

core/docs/usecase4.md
Go to the documentation of this file.
1 # Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
2 
3 @page core_usecase4 Logging
4 
5 @note SW Release Applicability: This tutorial is applicable to modules in both **NVIDIA DriveWorks** and **NVIDIA DRIVE Software** releases.
6 
7 The NVDIA<sup>&reg;</sup> DriveWorks library implements simple logging, by
8 passing a log message to a user-specified callback.
9 
10 To initialize a logger instance, pass a callback method to the logger
11 initialization. The call must occur before SDK context initialization.
12 For more information, see @ref core_logger_group.
13 
14 ```{.cpp}
15 // initialize global logger instance to push all logs to the given callback
16 dwLogger_initialize(myLoggerCallback());
17 
18 // log everything above WARN level, i.e. WARN and ERROR
19 dwLogger_setLogLevel(DW_LOG_WARN);
20 
21 dwContextParameters sdkParams = {};
22 dwVersion sdkVersion;
23 dwGetVersion(&sdkVersion);
24 dwInitialize(&sdk, sdkVersion, &sdkParams);
25 
26 ```
27 @note Currently, logger is a global instance and is not bound to a specific SDK context.
28 
29 A callback method that accepts log messages has the following syntax:
30 
31 ```{.cpp}
32 void myLoggerCallback(dwContextHandle_t context, dwLoggerVerbosity type, const char* msg)
33 {
34  ...
35 }
36 ```
37