blob: 39afd0c72abec6ee323623562f78d05dbd7a3e34 [file] [log] [blame]
William Luhfb376ce2015-08-13 10:41:58 -07001/*
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>
Mark Salyzyn5e6d9412016-10-17 14:28:00 -070018#include <stdint.h>
William Luhfb376ce2015-08-13 10:41:58 -070019
Mark Salyzyn5e6d9412016-10-17 14:28:00 -070020#include <log/log.h>
Mark Salyzynceaebf22016-11-18 10:45:45 -080021#include <log/log_event_list.h>
William Luhfb376ce2015-08-13 10:41:58 -070022
William Luhfb376ce2015-08-13 10:41:58 -070023#define MAX_SUBTAG_LEN 32
24
Tom Cherry3d6a8782019-02-08 11:46:19 -080025int __android_log_error_write(int tag, const char* subTag, int32_t uid, const char* data,
26 uint32_t dataLen) {
Mark Salyzyn6e315682017-03-09 08:09:43 -080027 int ret = -EINVAL;
William Luhfb376ce2015-08-13 10:41:58 -070028
Mark Salyzyn6e315682017-03-09 08:09:43 -080029 if (subTag && (data || !dataLen)) {
30 android_log_context ctx = create_android_logger(tag);
William Luhfb376ce2015-08-13 10:41:58 -070031
Mark Salyzyn6e315682017-03-09 08:09:43 -080032 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 }
Mark Salyzyn581ab662016-02-25 09:02:09 -080042 }
Mark Salyzyn6e315682017-03-09 08:09:43 -080043 }
44 android_log_destroy(&ctx);
William Luhfb376ce2015-08-13 10:41:58 -070045 }
Mark Salyzyn6e315682017-03-09 08:09:43 -080046 }
47 return ret;
William Luhfb376ce2015-08-13 10:41:58 -070048}