William Luh | ebfe930 | 2015-08-13 10:41:58 -0700 | [diff] [blame] | 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> |
Mark Salyzyn | ec22bca | 2016-10-17 14:28:00 -0700 | [diff] [blame] | 18 | #include <stdint.h> |
William Luh | ebfe930 | 2015-08-13 10:41:58 -0700 | [diff] [blame] | 19 | |
Mark Salyzyn | ec22bca | 2016-10-17 14:28:00 -0700 | [diff] [blame] | 20 | #include <log/log.h> |
Mark Salyzyn | 7c9c282 | 2016-11-18 10:45:45 -0800 | [diff] [blame] | 21 | #include <log/log_event_list.h> |
William Luh | ebfe930 | 2015-08-13 10:41:58 -0700 | [diff] [blame] | 22 | |
Mark Salyzyn | e188bd9 | 2016-03-01 13:45:42 -0800 | [diff] [blame] | 23 | #include "log_portability.h" |
Mark Salyzyn | 53cf047 | 2016-03-10 08:25:33 -0800 | [diff] [blame] | 24 | |
William Luh | ebfe930 | 2015-08-13 10:41:58 -0700 | [diff] [blame] | 25 | #define MAX_SUBTAG_LEN 32 |
| 26 | |
Mark Salyzyn | a2d59f8 | 2017-03-09 08:09:43 -0800 | [diff] [blame] | 27 | LIBLOG_ABI_PUBLIC int __android_log_error_write(int tag, const char* subTag, |
| 28 | int32_t uid, const char* data, |
| 29 | uint32_t dataLen) { |
| 30 | int ret = -EINVAL; |
William Luh | ebfe930 | 2015-08-13 10:41:58 -0700 | [diff] [blame] | 31 | |
Mark Salyzyn | a2d59f8 | 2017-03-09 08:09:43 -0800 | [diff] [blame] | 32 | if (subTag && (data || !dataLen)) { |
| 33 | android_log_context ctx = create_android_logger(tag); |
William Luh | ebfe930 | 2015-08-13 10:41:58 -0700 | [diff] [blame] | 34 | |
Mark Salyzyn | a2d59f8 | 2017-03-09 08:09:43 -0800 | [diff] [blame] | 35 | ret = -ENOMEM; |
| 36 | if (ctx) { |
| 37 | ret = android_log_write_string8_len(ctx, subTag, MAX_SUBTAG_LEN); |
| 38 | if (ret >= 0) { |
| 39 | ret = android_log_write_int32(ctx, uid); |
| 40 | if (ret >= 0) { |
| 41 | ret = android_log_write_string8_len(ctx, data, dataLen); |
| 42 | if (ret >= 0) { |
| 43 | ret = android_log_write_list(ctx, LOG_ID_EVENTS); |
| 44 | } |
Mark Salyzyn | b92e750 | 2016-02-25 09:02:09 -0800 | [diff] [blame] | 45 | } |
Mark Salyzyn | a2d59f8 | 2017-03-09 08:09:43 -0800 | [diff] [blame] | 46 | } |
| 47 | android_log_destroy(&ctx); |
William Luh | ebfe930 | 2015-08-13 10:41:58 -0700 | [diff] [blame] | 48 | } |
Mark Salyzyn | a2d59f8 | 2017-03-09 08:09:43 -0800 | [diff] [blame] | 49 | } |
| 50 | return ret; |
William Luh | ebfe930 | 2015-08-13 10:41:58 -0700 | [diff] [blame] | 51 | } |