Haivision / srt

Secure, Reliable, Transport
https://www.srtalliance.org
Mozilla Public License 2.0
3.11k stars 850 forks source link

[FR] Structured logging, with events and statistics #1122

Open cdunklau opened 4 years ago

cdunklau commented 4 years ago

Is your feature request related to a problem? Please describe. As far as I can tell, srt-live-transmit does not provide a defined logging output format for machine interpretation. This makes it difficult to tell e.g. the state of a connection from a script or test application with confidence, since the exact log format is presumably not specified and could change between versions.

Describe the solution you'd like I'd like to be able to configure srt-live-transmit so it outputs everything in a standardized, parseable format, with some reasonable policy to allow for backwards-compatible changes and deprecation.

The output should include:

Each message should contain a top-level value that declares the message's schema. This prevents a consumer from needing to check several values to determine how a message should be interpreted. It should also contain a timestamp with reasonable (millisecond?) resolution.

Some examples follow, and assume JSON (which is probably the most reasonable). I'm not attached to the particular details of the schema, as long as it's clearly defined and straightforward to interpret programmatically.

Log message:

{
  "type": "LOG",
  "level": "INFO",
  "timestamp": "2020-02-07T12:48:28.963Z",
  "message": "Opening SRT target caller on dest.example.com:14901"
}

Separate connection state event:

  "detail": {
    "type": "CONNECTION_EVENT",
    "event": "STARTED_CONNECTING",
    "target": "srt://dest.example.com:14901"
  }

Alternatively, the log message combined with connection state event:

{
  "type": "LOG",
  "level": "INFO",
  "timestamp": "2020-02-07T12:48:28.963Z",
  "message": "Opening SRT target caller on dest.example.com:14901",
  "detail": {
    "type": "CONNECTION_EVENT",
    "event": "STARTED_CONNECTING",
    "target": "srt://dest.example.com:14901"
  }
}

Statistics report:

{
  "type": "STATS",
  "timestamp": "2020-02-07T12:48:28.963Z",
  "sid": 432830566,
  "time": 1329,
  "window": { },
  "link": { },
  "send": { },
  "recv": { }
}

Describe alternatives you've considered The statistics output is quite nice, but getting connection state change events currently requires manual parsing of the log messages.

Additional context Related to #908, and perhaps #55

mbakholdina commented 4 years ago

Hi @cdunklau, thank you for your suggestions. We will consider them during revising and improving the SRT stats API (see #1215) functionality.