1 /* 2 * Copyright 2013 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 #pragma once 18 19 #include <utils/Errors.h> 20 #include <utils/Singleton.h> 21 22 #include <cstdint> 23 #include <string_view> 24 25 namespace android { 26 27 class EventLog : public Singleton<EventLog> { 28 29 public: 30 static void logFrameDurations(const std::string_view& name, const int32_t* durations, 31 size_t numDurations); 32 33 protected: 34 EventLog(); 35 36 private: 37 /* 38 * EventLogBuffer is a helper class to construct an in-memory event log 39 * tag. In this version the buffer is not dynamic, so write operation can 40 * fail if there is not enough space in the temporary buffer. 41 * Once constructed, the buffer can be logger by calling the log() 42 * method. 43 */ 44 45 class TagBuffer { 46 enum { STORAGE_MAX_SIZE = 128 }; 47 int32_t mPos; 48 int32_t mTag; 49 bool mOverflow; 50 char mStorage[STORAGE_MAX_SIZE]; 51 public: 52 explicit TagBuffer(int32_t tag); 53 54 void startList(int8_t count); 55 void endList(); 56 57 void writeInt32(int32_t); 58 void writeInt64(int64_t); 59 void writeString(const std::string_view&); 60 61 void log(); 62 }; 63 64 friend class Singleton<EventLog>; 65 EventLog(const EventLog&); 66 EventLog& operator =(const EventLog&); 67 68 enum { LOGTAG_SF_FRAME_DUR = 60100 }; 69 void doLogFrameDurations(const std::string_view& name, const int32_t* durations, 70 size_t numDurations); 71 }; 72 73 } // namespace android 74