/*
 * 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.
 */

syntax = "proto2";

package com.android.internal.protolog;

option java_multiple_files = true;

import "frameworks/base/core/proto/android/privacy.proto";

/* represents a single log entry */
message ProtoLogMessage {
    option (.android.msg_privacy).dest = DEST_LOCAL;

    /* log statement identifier, created from message string and log level. */
    optional sfixed32 message_hash_legacy = 1 [deprecated = true];
    /* log time, relative to the elapsed system time clock. */
    optional fixed64 elapsed_realtime_nanos = 2;
    /* string parameters passed to the log call. */
    repeated string str_params = 3;
    /* integer parameters passed to the log call. */
    repeated sint64 sint64_params = 4 [packed=true];
    /* floating point parameters passed to the log call. */
    repeated double double_params = 5 [packed=true];
    /* boolean parameters passed to the log call. */
    repeated bool boolean_params = 6 [packed=true];

    /* log statement identifier, created from message string and log level. */
    optional sfixed64 message_hash = 7;
}

/* represents a log file containing ProtoLog log entries.
   Encoded, it should start with 0x9 0x50 0x52 0x4f 0x54 0x4f 0x4c 0x4f 0x47 (.PROTOLOG), such
   that they can be easily identified. */
message ProtoLogFileProto {
    option (.android.msg_privacy).dest = DEST_LOCAL;

    /* constant; MAGIC_NUMBER = (long) MAGIC_NUMBER_H << 32 | MagicNumber.MAGIC_NUMBER_L
       (this is needed because enums have to be 32 bits and there's no nice way to put 64bit
        constants into .proto files. */
    enum MagicNumber {
        INVALID = 0;
        MAGIC_NUMBER_L = 0x544f5250; /* PROT (little-endian ASCII) */
        MAGIC_NUMBER_H = 0x474f4c4f; /* OLOG (little-endian ASCII) */
    }

    /* the magic number header */
    optional fixed64 magic_number = 1;
    /* log proto version. */
    optional string version = 2;
    /* offset between real-time clock and elapsed system time clock in milliseconds.
       Calculated as: (System.currentTimeMillis() - (SystemClock.elapsedRealtimeNanos() / 1000000) */
    optional fixed64 realTimeToElapsedTimeOffsetMillis = 3;
    /* log entries */
    repeated ProtoLogMessage log = 4;
}