Repository navigation
Expand file tree
/
Copy pathLogging.cpp
More file actions
79 lines (78 loc) · 2.21 KB
/
Copy pathLogging.cpp
File metadata and controls
79 lines (78 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* Copyright (c) Qualcomm Innovation Center, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <executorch/backends/qualcomm/runtime/Logging.h>
#include <cstdarg>
#include <cstdio>
#ifdef __ANDROID__
#include <android/log.h>
#endif
#ifdef __hexagon__
#include "HAP_farf.h"
#endif
namespace executorch {
namespace backends {
namespace qnn {
void Log(QnnExecuTorchLogLevel log_level, const char* format, ...) {
va_list args;
va_start(args, format);
const char* serverity_name;
switch (log_level) {
case QnnExecuTorchLogLevel::kLogLevelVerbose:
serverity_name = "VERBOSE";
break;
case QnnExecuTorchLogLevel::kLogLevelInfo:
serverity_name = "INFO";
break;
case QnnExecuTorchLogLevel::kLogLevelWarn:
serverity_name = "WARNING";
break;
case QnnExecuTorchLogLevel::kLogLevelError:
serverity_name = "ERROR";
break;
case QnnExecuTorchLogLevel::kLogLevelDebug:
serverity_name = "DEBUG";
break;
default:
serverity_name = "Unknown severity";
break;
}
#ifdef __ANDROID__
int android_severity = ANDROID_LOG_DEBUG;
switch (log_level) {
case QnnExecuTorchLogLevel::kLogLevelInfo:
android_severity = ANDROID_LOG_INFO;
break;
case QnnExecuTorchLogLevel::kLogLevelWarn:
android_severity = ANDROID_LOG_WARN;
break;
case QnnExecuTorchLogLevel::kLogLevelError:
android_severity = ANDROID_LOG_ERROR;
break;
case QnnExecuTorchLogLevel::kLogLevelVerbose:
case QnnExecuTorchLogLevel::kLogLevelDebug:
default:
android_severity = ANDROID_LOG_DEBUG;
break;
}
__android_log_vprint(android_severity, "[Qnn ExecuTorch]", format, args);
#endif
#ifndef __hexagon__
fprintf(stderr, "[%s] [Qnn ExecuTorch]: ", serverity_name);
vfprintf(stderr, format, args);
va_end(args);
fputc('\n', stderr);
#else
char buf[QNN_EXECUTORCH_FARF_BUF_SIZE] = {0};
vsnprintf(buf, QNN_EXECUTORCH_FARF_BUF_SIZE, format, args);
va_end(args);
FARF(RUNTIME_HIGH, "[%s] [Qnn ExecuTorch]: %s\n", serverity_name, buf);
#endif
}
} // namespace qnn
} // namespace backends
} // namespace executorch