• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2019 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 #include "tensorflow/lite/minimal_logging.h"
17 
18 #include <syslog.h>
19 #include <cstdarg>
20 
21 namespace tflite {
22 namespace logging_internal {
23 namespace {
24 
GetPlatformSeverity(LogSeverity severity)25 int GetPlatformSeverity(LogSeverity severity) {
26   switch (severity) {
27     case TFLITE_LOG_INFO:
28       return LOG_INFO;
29     case TFLITE_LOG_WARNING:
30       return LOG_WARNING;
31     case TFLITE_LOG_ERROR:
32       return LOG_ERR;
33     default:
34       return LOG_DEBUG;
35   }
36 }
37 
38 }  // namespace
39 
LogFormatted(LogSeverity severity,const char * format,va_list args)40 void MinimalLogger::LogFormatted(LogSeverity severity, const char* format,
41                                  va_list args) {
42   // TODO(b/123704468): Use os_log when available.
43   vsyslog(GetPlatformSeverity(severity), format, args);
44 }
45 
46 }  // namespace logging_internal
47 }  // namespace tflite
48