Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e92461d8 authored by Tom Cherry's avatar Tom Cherry Committed by Gerrit Code Review
Browse files

Merge changes I62be2c1e,I292662fc

* changes:
  liblog: remove more unused code
  liblog: remove the last of the transport structs
parents f5a329f1 b47aa2a5
Loading
Loading
Loading
Loading
+2 −10
Original line number Diff line number Diff line
@@ -49,14 +49,6 @@
#define TRACE(...) ((void)0)
#endif

static void FakeClose();
static int FakeWrite(log_id_t log_id, struct timespec* ts, struct iovec* vec, size_t nr);

struct android_log_transport_write fakeLoggerWrite = {
    .close = FakeClose,
    .write = FakeWrite,
};

typedef struct LogState {
  bool initialized = false;
  /* global minimum priority */
@@ -453,7 +445,7 @@ static void ShowLog(int logPrio, const char* tag, const char* msg) {
 *  tag (N bytes -- null-terminated ASCII string)
 *  message (N bytes -- null-terminated ASCII string)
 */
static int FakeWrite(log_id_t log_id, struct timespec*, struct iovec* vector, size_t count) {
int FakeWrite(log_id_t log_id, struct timespec*, struct iovec* vector, size_t count) {
  /* Make sure that no-one frees the LogState while we're using it.
   * Also guarantees that only one thread is in showLog() at a given
   * time (if it matters).
@@ -519,7 +511,7 @@ static int FakeWrite(log_id_t log_id, struct timespec*, struct iovec* vector, si
 * call is in the exit handler. Logging can continue in the exit handler to
 * help debug HOST tools ...
 */
static void FakeClose() {
void FakeClose() {
  auto lock = std::lock_guard{*fake_log_mutex};

  memset(&log_state, 0, sizeof(log_state));
+4 −6
Original line number Diff line number Diff line
@@ -18,16 +18,14 @@

#include <sys/types.h>

#include "log_portability.h"
#include "uio.h"
#include <android/log.h>

struct iovec;
#include "log_portability.h"

__BEGIN_DECLS

int fakeLogOpen(const char* pathName);
int fakeLogClose(int fd);
ssize_t fakeLogWritev(int fd, const struct iovec* vector, int count);
void FakeClose();
int FakeWrite(log_id_t log_id, struct timespec* ts, struct iovec* vec, size_t nr);

int __android_log_is_loggable(int prio, const char*, int def);
int __android_log_is_loggable_len(int prio, const char*, size_t, int def);
+0 −2
Original line number Diff line number Diff line
@@ -35,8 +35,6 @@

#include <string>

#include <cutils/sockets.h>
#include <private/android_filesystem_config.h>
#include <private/android_logger.h>

#include "logger.h"
+5 −12
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@
 * limitations under the License.
 */

#include "logd_writer.h"

#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
@@ -32,7 +34,6 @@

#include <shared_mutex>

#include <cutils/sockets.h>
#include <private/android_filesystem_config.h>
#include <private/android_logger.h>

@@ -41,14 +42,6 @@
#include "rwlock.h"
#include "uio.h"

static int LogdWrite(log_id_t logId, struct timespec* ts, struct iovec* vec, size_t nr);
static void LogdClose();

struct android_log_transport_write logdLoggerWrite = {
    .close = LogdClose,
    .write = LogdWrite,
};

static int logd_socket;
static RwLock logd_socket_lock;

@@ -90,7 +83,7 @@ static void ResetSocket(int old_socket) {
  OpenSocketLocked();
}

static void LogdClose() {
void LogdClose() {
  auto lock = std::unique_lock{logd_socket_lock};
  if (logd_socket > 0) {
    close(logd_socket);
@@ -98,7 +91,7 @@ static void LogdClose() {
  logd_socket = 0;
}

static int LogdWrite(log_id_t logId, struct timespec* ts, struct iovec* vec, size_t nr) {
int LogdWrite(log_id_t logId, struct timespec* ts, struct iovec* vec, size_t nr) {
  ssize_t ret;
  static const unsigned headerLength = 1;
  struct iovec newVec[nr + headerLength];
@@ -119,7 +112,7 @@ static int LogdWrite(log_id_t logId, struct timespec* ts, struct iovec* vec, siz
  }

  /* logd, after initialization and priv drop */
  if (__android_log_uid() == AID_LOGD) {
  if (getuid() == AID_LOGD) {
    /*
     * ignore log messages we send to ourself (logd).
     * Such log messages are often generated by libraries we depend on

liblog/logd_writer.h

0 → 100644
+24 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include <stddef.h>

#include <android/log.h>

int LogdWrite(log_id_t logId, struct timespec* ts, struct iovec* vec, size_t nr);
void LogdClose();
Loading