1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <platform/api/logging.h>
18 
19 #include <android-base/logging.h>
20 
21 namespace openscreen {
22 
IsLoggingOn(LogLevel level,const char * file)23 bool IsLoggingOn(LogLevel level, const char* file) {
24     return true;
25 }
26 
LogWithLevel(LogLevel level,const char * file,int line,std::stringstream desc)27 void LogWithLevel(LogLevel level, const char* file, int line, std::stringstream desc) {
28     android::base::LogSeverity severity;
29     switch (level) {
30         case LogLevel::kInfo:
31             severity = android::base::LogSeverity::INFO;
32             break;
33         case LogLevel::kWarning:
34             severity = android::base::LogSeverity::WARNING;
35             break;
36         case LogLevel::kError:
37             severity = android::base::LogSeverity::ERROR;
38             break;
39         case LogLevel::kFatal:
40             severity = android::base::LogSeverity::FATAL;
41             break;
42         default:
43             severity = android::base::LogSeverity::DEBUG;
44             break;
45     }
46     LOG(severity) << std::string("(") + file + ":" + std::to_string(line) + ") " + desc.str();
47 }
48 
Break()49 [[noreturn]] void Break() {
50     std::abort();
51 }
52 
53 }  // namespace openscreen
54