• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 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 <errno.h>
18 #include <stdint.h>
19 
20 #include <log/log.h>
21 #include <log/log_event_list.h>
22 
23 #define MAX_SUBTAG_LEN 32
24 
__android_log_error_write(int tag,const char * subTag,int32_t uid,const char * data,uint32_t dataLen)25 int __android_log_error_write(int tag, const char* subTag, int32_t uid, const char* data,
26                               uint32_t dataLen) {
27   int ret = -EINVAL;
28 
29   if (subTag && (data || !dataLen)) {
30     android_log_context ctx = create_android_logger(tag);
31 
32     ret = -ENOMEM;
33     if (ctx) {
34       ret = android_log_write_string8_len(ctx, subTag, MAX_SUBTAG_LEN);
35       if (ret >= 0) {
36         ret = android_log_write_int32(ctx, uid);
37         if (ret >= 0) {
38           ret = android_log_write_string8_len(ctx, data, dataLen);
39           if (ret >= 0) {
40             ret = android_log_write_list(ctx, LOG_ID_EVENTS);
41           }
42         }
43       }
44       android_log_destroy(&ctx);
45     }
46   }
47   return ret;
48 }
49