1/*
2 * Copyright (C) 2017 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
17syntax = "proto2";
18
19package com.android.server.protolog;
20
21option java_multiple_files = true;
22
23import "frameworks/base/core/proto/android/privacy.proto";
24
25/* represents a single log entry */
26message ProtoLogMessage {
27    option (.android.msg_privacy).dest = DEST_LOCAL;
28
29    /* log statement identifier, created from message string and log level. */
30    optional sfixed32 message_hash = 1;
31    /* log time, relative to the elapsed system time clock. */
32    optional fixed64 elapsed_realtime_nanos = 2;
33    /* string parameters passed to the log call. */
34    repeated string str_params = 3;
35    /* integer parameters passed to the log call. */
36    repeated sint64 sint64_params = 4 [packed=true];
37    /* floating point parameters passed to the log call. */
38    repeated double double_params = 5 [packed=true];
39    /* boolean parameters passed to the log call. */
40    repeated bool boolean_params = 6 [packed=true];
41}
42
43/* represents a log file containing ProtoLog log entries.
44   Encoded, it should start with 0x9 0x50 0x52 0x4f 0x54 0x4f 0x4c 0x4f 0x47 (.PROTOLOG), such
45   that they can be easily identified. */
46message ProtoLogFileProto {
47    option (.android.msg_privacy).dest = DEST_LOCAL;
48
49    /* constant; MAGIC_NUMBER = (long) MAGIC_NUMBER_H << 32 | MagicNumber.MAGIC_NUMBER_L
50       (this is needed because enums have to be 32 bits and there's no nice way to put 64bit
51        constants into .proto files. */
52    enum MagicNumber {
53        INVALID = 0;
54        MAGIC_NUMBER_L = 0x544f5250; /* PROT (little-endian ASCII) */
55        MAGIC_NUMBER_H = 0x474f4c4f; /* OLOG (little-endian ASCII) */
56    }
57
58    /* the magic number header */
59    optional fixed64 magic_number = 1;
60    /* log proto version. */
61    optional string version = 2;
62    /* offset between real-time clock and elapsed system time clock in miliseconds.
63       Calculated as: (System.currentTimeMillis() - (SystemClock.elapsedRealtimeNanos() / 1000000) */
64    optional fixed64 realTimeToElapsedTimeOffsetMillis = 3;
65    /* log entries */
66    repeated ProtoLogMessage log = 4;
67}
68