8000 KERNEL: Refine logger and error · Issue #913 · ossrs/srs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
KERNEL: Refine logger and error #913
Closed
@winlinvip

Description

@winlinvip

The logger should only log the "BIG" events, which are not error. In addition, logger should support context. The errors should, not only the error code, but indicates the context such as the stack and description. For detail information about errors, please read https://gocn.io/article/348.

For SRS, it confuses the error and logger, that is SRS output error in logger and in each function calls. There is a example, when error cames from SrsSource::on_video_imp, each function will print a error:

int SrsSource::on_video_imp(SrsSharedPtrMessage* msg) {
    if ((ret = hub->on_video(msg, is_sequence_header)) != ERROR_SUCCESS) {
        srs_error("origin hub error, ret=%d", ret);
        return ret;
    }
}

int SrsOriginHub::on_video(SrsSharedPtrMessage* shared_video, bool is_sequence_header) {
    if ((ret = format->on_video(msg)) != ERROR_SUCCESS) {
        srs_error("Codec parse video failed, ret=%d", ret);
        return ret;
    }
}

int SrsFormat::on_video(int64_t timestamp, char* data, int size) {
    return video_avc_demux(buffer, timestamp);
}

int SrsFormat::video_avc_demux(SrsBuffer* stream, int64_t timestamp) {
    if (!stream->require(4)) {
        ret = ERROR_HLS_DECODE_ERROR;
        srs_error("avc decode avc_packet_type failed. ret=%d", ret);
        return ret;
    }
}

Let's have a look what happends when there is a decode error:

avc decode avc_packet_type failed. ret=3001
Codec parse video failed, ret=3001
origin hub error, ret=3001

Is it useful? Yes, it's useful than just an error code like Failed, code is 3001, but it's not enough:

  1. There is no stack info.
  2. The logs are not simply enough.

I'll be better if the error is like this:

Error processing video, code=3001 : origin hub : codec parser : avc decoder
[100] video_avc_demux() at [srs_kernel_codec.cpp:676]
[100] on_video() at [srs_app_source.cpp:1076]
[101] on_video_imp() at [srs_app_source:2357]

For logger, it should log some important events, the error should be one event.

Metadata

Metadata

Assignees

Labels

EnglishNativeThis issue is conveyed exclusively in English.EnhancementImprovement or enhancement.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0