micro_error_reporter.cc 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* Copyright 2018 The TensorFlow Authors. All Rights Reserved.
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.
  11. ==============================================================================*/
  12. #include "tensorflow/lite/micro/micro_error_reporter.h"
  13. #include <cstdarg>
  14. #ifndef TF_LITE_STRIP_ERROR_STRINGS
  15. #include "tensorflow/lite/micro/debug_log.h"
  16. #include "tensorflow/lite/micro/micro_string.h"
  17. #endif
  18. namespace tflite {
  19. int MicroErrorReporter::Report(const char* format, va_list args) {
  20. #ifndef TF_LITE_STRIP_ERROR_STRINGS
  21. // Only pulling in the implementation of this function for builds where we
  22. // expect to make use of it to be extra cautious about not increasing the code
  23. // size.
  24. static constexpr int kMaxLogLen = 256;
  25. char log_buffer[kMaxLogLen];
  26. MicroVsnprintf(log_buffer, kMaxLogLen, format, args);
  27. DebugLog(log_buffer);
  28. DebugLog("\r\n");
  29. #endif
  30. return 0;
  31. }
  32. } // namespace tflite