• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2017 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 // #define LOG_NDEBUG 0
18 #define LOG_TAG "audio_utils_ErrorLog"
19 #include <log/log.h>
20 
21 #include <audio_utils/ErrorLog.h>
22 
23 using namespace android;
24 
error_log_create(size_t entries,int64_t aggregate_ns)25 error_log_t *error_log_create(size_t entries, int64_t aggregate_ns)
26 {
27     return reinterpret_cast<error_log_t *>
28             (new(std::nothrow) ErrorLog<int32_t>(entries, aggregate_ns));
29 }
30 
error_log_log(error_log_t * error_log,int32_t code,int64_t now_ns)31 void error_log_log(error_log_t *error_log, int32_t code, int64_t now_ns)
32 {
33     if (error_log == nullptr) {
34         return;
35     }
36     reinterpret_cast<ErrorLog<int32_t> *>(error_log)->log(code, now_ns);
37 }
38 
error_log_dump(error_log_t * error_log,int fd,const char * prefix,size_t lines,int64_t limit_ns)39 int error_log_dump(
40         error_log_t *error_log, int fd, const char *prefix, size_t lines, int64_t limit_ns)
41 {
42     if (error_log == nullptr) {
43         return BAD_VALUE;
44     }
45     return reinterpret_cast<ErrorLog<int32_t> *>(error_log)->dump(fd, prefix, lines, limit_ns);
46 }
47 
error_log_destroy(error_log_t * error_log)48 void error_log_destroy(error_log_t *error_log)
49 {
50     delete reinterpret_cast<ErrorLog<int32_t> *>(error_log);
51 }
52