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

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

Merge "Revert "Modularize logd.""

parents e33e1a82 3096818c
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ cc_library_static {
        "FlushCommand.cpp",
        "LogBuffer.cpp",
        "LogBufferElement.cpp",
        "LogBufferInterface.cpp",
        "LogTimes.cpp",
        "LogStatistics.cpp",
        "LogWhiteBlackList.cpp",
+4 −5
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@
#include <sysutils/SocketClient.h>

#include "LogBufferElement.h"
#include "LogBufferInterface.h"
#include "LogStatistics.h"
#include "LogTags.h"
#include "LogTimes.h"
@@ -75,7 +74,7 @@ static bool isMonotonic(const log_time& mono) {

typedef std::list<LogBufferElement*> LogBufferElementCollection;

class LogBuffer : public LogBufferInterface {
class LogBuffer {
    LogBufferElementCollection mLogElements;
    pthread_rwlock_t mLogElementsLock;

@@ -108,14 +107,14 @@ class LogBuffer : public LogBufferInterface {
    LastLogTimes& mTimes;

    explicit LogBuffer(LastLogTimes* times);
    ~LogBuffer() override;
    ~LogBuffer();
    void init();
    bool isMonotonic() {
        return monotonic;
    }

    int log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid, pid_t tid,
            const char* msg, uint16_t len) override;
    int log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid, pid_t tid, const char* msg,
            uint16_t len);
    // lastTid is an optional context to help detect if the last previous
    // valid message was from the same source so we can differentiate chatty
    // filter types (identical or expired)

logd/LogBufferInterface.cpp

deleted100644 → 0
+0 −21
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 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.
 */

#include "LogBufferInterface.h"

LogBufferInterface::LogBufferInterface() {
}
LogBufferInterface::~LogBufferInterface() {}
 No newline at end of file

logd/LogBufferInterface.h

deleted100644 → 0
+0 −40
Original line number Diff line number Diff line
/*
 * Copyright (C) 2012-2014 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.
 */

#ifndef _LOGD_LOG_BUFFER_INTERFACE_H__
#define _LOGD_LOG_BUFFER_INTERFACE_H__

#include <sys/types.h>

#include <android-base/macros.h>
#include <log/log_id.h>
#include <log/log_time.h>

// Abstract interface that handles log when log available.
class LogBufferInterface {
   public:
    LogBufferInterface();
    virtual ~LogBufferInterface();
    // Handles a log entry when available in LogListener.
    // Returns the size of the handled log message.
    virtual int log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid,
                    pid_t tid, const char* msg, uint16_t len) = 0;

   private:
    DISALLOW_COPY_AND_ASSIGN(LogBufferInterface);
};

#endif  // _LOGD_LOG_BUFFER_INTERFACE_H__
+6 −10
Original line number Diff line number Diff line
@@ -30,9 +30,8 @@
#include "LogListener.h"
#include "LogUtils.h"

LogListener::LogListener(LogBufferInterface* buf, LogReader* reader)
    : SocketListener(getLogSocket(), false), logbuf(buf), reader(reader) {
}
LogListener::LogListener(LogBuffer* buf, LogReader* reader)
    : SocketListener(getLogSocket(), false), logbuf(buf), reader(reader) {}

bool LogListener::onDataAvailable(SocketClient* cli) {
    static bool name_set;
@@ -107,14 +106,11 @@ bool LogListener::onDataAvailable(SocketClient* cli) {
    // NB: hdr.msg_flags & MSG_TRUNC is not tested, silently passing a
    // truncated message to the logs.

    if (logbuf != nullptr) {
        int res = logbuf->log(
            logId, header->realtime, cred->uid, cred->pid, header->tid, msg,
    int res = logbuf->log(logId, header->realtime, cred->uid, cred->pid, header->tid, msg,
                          ((size_t)n <= UINT16_MAX) ? (uint16_t)n : UINT16_MAX);
        if (res > 0 && reader != nullptr) {
    if (res > 0) {
        reader->notifyNewLog(static_cast<log_mask_t>(1 << logId));
    }
    }

    return true;
}
Loading