1 /* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 
16 // Implementation for the DebugLog() function that prints to the debug logger on
17 // an generic Cortex-M device.
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif  // __cplusplus
22 
23 #include "tensorflow/lite/micro/debug_log.h"
24 
25 #include "tensorflow/lite/micro/cortex_m_generic/debug_log_callback.h"
26 
27 static DebugLogCallback debug_log_callback = nullptr;
28 
RegisterDebugLogCallback(void (* cb)(const char * s))29 void RegisterDebugLogCallback(void (*cb)(const char* s)) {
30   debug_log_callback = cb;
31 }
32 
DebugLog(const char * s)33 void DebugLog(const char* s) {
34 #ifndef TF_LITE_STRIP_ERROR_STRINGS
35   if (debug_log_callback != nullptr) {
36     debug_log_callback(s);
37   }
38 #endif
39 }
40 
41 #ifdef __cplusplus
42 }  // extern "C"
43 #endif  // __cplusplus
44