blob: 645b492cab348a2cdff8b5d269da6b04c074c2f7 [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library fuchsia.diagnostics.stream;
using zx;
/// Maximum number of arguments that can be encoded per record, as specified by the tracing format:
///
/// https://fuchsia.dev/fuchsia-src/development/tracing/trace-format#arguments
const MAX_ARGS uint32 = 15;
/// A small(ish) limit on the length of argument names is used because argument names are expected
/// to be used repeatedly, many times.
const MAX_ARG_NAME_LENGTH uint32 = 256;
/// The maximum string length which we can encode into the tracing format.
const MAX_TEXT_ARG_LENGTH uint32 = 32768;
/// Type alias for logging severity.
alias RawSeverity = uint8;
/// A record in the diagnostic stream.
type Record = struct {
/// The monotonic time at which the record was generated.
timestamp zx.Time;
/// Severity of the record.
severity RawSeverity;
/// The key-value pairs which make up this record.
arguments vector<Argument>:MAX_ARGS;
};
/// A named key-value pair in the diagnostic record.
type Argument = struct {
/// The name of the argument.
name string:MAX_ARG_NAME_LENGTH;
/// The value of the argument.
value Value;
};
/// An argument value which can be one of several types.
type Value = flexible union {
/// A signed integral argument.
1: signed_int int64;
/// An unsigned integral argument.
2: unsigned_int uint64;
/// A double-precision floating-point argument.
3: floating float64;
/// A UTF8 text argument.
4: text string:MAX_TEXT_ARG_LENGTH;
/// A boolean argument.
5: boolean bool;
};