blob: 52075147ef9ea54dfd8f10669b819fa6f203cadb [file] [log] [blame]
Mathias Agopian85cce372013-06-04 21:50:31 -07001/*
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#include <stdint.h>
18#include <utils/Errors.h>
19#include <utils/Singleton.h>
20
21#ifndef ANDROID_SF_EVENTLOG_H
22#define ANDROID_SF_EVENTLOG_H
23
24// ---------------------------------------------------------------------------
25namespace android {
26// ---------------------------------------------------------------------------
27
28class String8;
29
30class EventLog : public Singleton<EventLog> {
31
32public:
Jamie Gennis6547ff42013-07-16 20:12:42 -070033 static void logFrameDurations(const String8& window,
34 const int32_t* durations, size_t numDurations);
Mathias Agopian85cce372013-06-04 21:50:31 -070035
36protected:
37 EventLog();
38
39private:
40 /*
41 * EventLogBuffer is a helper class to construct an in-memory event log
42 * tag. In this version the buffer is not dynamic, so write operation can
43 * fail if there is not enough space in the temporary buffer.
44 * Once constructed, the buffer can be logger by calling the log()
45 * method.
46 */
47
48 class TagBuffer {
49 enum { STORAGE_MAX_SIZE = 128 };
50 int32_t mPos;
51 int32_t mTag;
52 bool mOverflow;
53 char mStorage[STORAGE_MAX_SIZE];
54 public:
55 TagBuffer(int32_t tag);
56
57 // starts list of items
58 void startList(int8_t count);
59 // terminates the list
60 void endList();
61 // write a 32-bit integer
62 void writeInt32(int32_t value);
63 // write a 64-bit integer
64 void writeInt64(int64_t value);
65 // write a C string
66 void writeString8(const String8& value);
67
68 // outputs the the buffer to the log
69 void log();
70 };
71
72 friend class Singleton<EventLog>;
73 EventLog(const EventLog&);
74 EventLog& operator =(const EventLog&);
75
Jamie Gennis6547ff42013-07-16 20:12:42 -070076 enum { LOGTAG_SF_FRAME_DUR = 60100 };
77 void doLogFrameDurations(const String8& window, const int32_t* durations,
78 size_t numDurations);
Mathias Agopian85cce372013-06-04 21:50:31 -070079};
80
81// ---------------------------------------------------------------------------
82}// namespace android
83// ---------------------------------------------------------------------------
84
85#endif /* ANDROID_SF_EVENTLOG_H */