blob: 2f1cd9b3e760797e279e86a1404fd3658f9a6d2e [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:
33 static void logJank(const String8& window, int32_t value);
34
35protected:
36 EventLog();
37
38private:
39 /*
40 * EventLogBuffer is a helper class to construct an in-memory event log
41 * tag. In this version the buffer is not dynamic, so write operation can
42 * fail if there is not enough space in the temporary buffer.
43 * Once constructed, the buffer can be logger by calling the log()
44 * method.
45 */
46
47 class TagBuffer {
48 enum { STORAGE_MAX_SIZE = 128 };
49 int32_t mPos;
50 int32_t mTag;
51 bool mOverflow;
52 char mStorage[STORAGE_MAX_SIZE];
53 public:
54 TagBuffer(int32_t tag);
55
56 // starts list of items
57 void startList(int8_t count);
58 // terminates the list
59 void endList();
60 // write a 32-bit integer
61 void writeInt32(int32_t value);
62 // write a 64-bit integer
63 void writeInt64(int64_t value);
64 // write a C string
65 void writeString8(const String8& value);
66
67 // outputs the the buffer to the log
68 void log();
69 };
70
71 friend class Singleton<EventLog>;
72 EventLog(const EventLog&);
73 EventLog& operator =(const EventLog&);
74
75 enum { LOGTAG_SF_JANK = 60100 };
76 void doLogJank(const String8& window, int32_t value);
77};
78
79// ---------------------------------------------------------------------------
80}// namespace android
81// ---------------------------------------------------------------------------
82
83#endif /* ANDROID_SF_EVENTLOG_H */