Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some mechanism to report events in a machine-readable manner #10

Open
cdunklau opened this issue Feb 4, 2020 · 2 comments
Open
Labels
enhancement New feature or request

Comments

@cdunklau
Copy link

cdunklau commented Feb 4, 2020

It would be nice if generate and receive had an option that would make them output events in a structured format, so another program could tell what's going on. The most useful events I can think of are:

  • connect attempt started (caller)
  • started listening (listener)
  • connection established (both)
  • connect attempt aborted (caller)
  • connection rejected (listener)
  • disconnected (both)

Newline-delimited JSON is probably the nicest to consume, perhaps with a structure like:

{
  "event": "CONNECT_REJECTED",
  "detail": {"reason": "incorrect passphrase"},
  "timestamp": "2020-02-04T16:45:05+00:00"
}
@maxsharabayko maxsharabayko added the enhancement New feature or request label Feb 6, 2020
@maxsharabayko
Copy link
Owner

Some thoughts for the future myself to load the context faster.
Currently the log message in case connect failed is the following:

16:39:45.195393 [D] SOCKET::SRT 0x1793EF27 ASYNC Connecting to srt://192.168.0.7:4200
16:39:48.288862 [D] SOCKET::SRT 0x1793EF27 connect ERROR connection failed, socket state 6
16:39:48.294114 [D] SOCKET::SRT 0x1793EF27 Closing. Releasing epolls
16:39:48.295424 [D] SOCKET::SRT 0x1793EF27 Closing

spdlog library is used for logging functionality. One way to go is to try to use spdlog's custom formatting.
Still, the message body itself will not be formatted this way. Example message body:

connect ERROR connection failed, socket state 6

The requested message should be:

{
  "event": "CONNECT_FAILED",
  "detail": {"reason": "timeout", "sockstate": 6},
  "timestamp": "16:39:48.288862"
}

Looks like a custom wrapper on top of SPD log is needed to handle this kind of output if json mode is enabled. 🤔

Or add additional logger to exception handlers to write json formatted output in case of an error. Then successfull events should be somehow handled as well.

@cdunklau
Copy link
Author

cdunklau commented Feb 7, 2020

I filed a similar request against SRT with a lot more detail: Haivision/srt#1122

It's probably worthwhile to use a similar format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants