alibaba / xquic

XQUIC Library released by Alibaba is a cross-platform implementation of QUIC and HTTP/3 protocol.
Apache License 2.0
1.65k stars 326 forks source link

[Feature]: document of `xqc_log` #206

Open Luffbee opened 2 years ago

Luffbee commented 2 years ago

Before request a new feature

Describe the feature you'd like supported

xqc_log use different format strings from printf, therefore, a document is needed.

Describe alternatives you've considered

No response

Additional context

No response

ruiqizhou commented 2 years ago

Does this document solve your problem? Event_log module docs

If not, could you please describe your requirements in more detail

Luffbee commented 2 years ago

No, I want a document describe the format string of xqc_log. For example, when I want to print a uint32_t, which format specifier should I use? I used %u once, but it's not working, so the format string is only similar to printf, I want to know the detail differences.

ruiqizhou commented 2 years ago

No, I want a document describe the format string of xqc_log. For example, when I want to print a uint32_t, which format specifier should I use? I used %u once, but it's not working, so the format string is only similar to printf, I want to know the detail differences.

We follow the Nginx Formatting. Maybe we should add this link to the document above?

typedef int32_t         xqc_int_t;
typedef uint32_t        xqc_uint_t;
typedef intptr_t        xqc_flag_t;
typedef uint8_t         xqc_bool_t;

so if you want to print uint32_t you should use %ui

Luffbee commented 2 years ago

This link is helpful, but I think it's still missing some details, for example, how should I print uint64_t? I looked src/core/ngx_string.c (mentioned in the link), it gives a better explanation. A comment or document like this will be good.

/*
 * supported formats:
 *    %[0][width][x][X]O        off_t
 *    %[0][width]T              time_t
 *    %[0][width][u][x|X]z      ssize_t/size_t
 *    %[0][width][u][x|X]d      int/u_int
 *    %[0][width][u][x|X]l      long
 *    %[0][width|m][u][x|X]i    ngx_int_t/ngx_uint_t
 *    %[0][width][u][x|X]D      int32_t/uint32_t
 *    %[0][width][u][x|X]L      int64_t/uint64_t
 *    %[0][width|m][u][x|X]A    ngx_atomic_int_t/ngx_atomic_uint_t
 *    %[0][width][.width]f      double, max valid number fits to %18.15f
 *    %P                        ngx_pid_t
 *    %M                        ngx_msec_t
 *    %r                        rlim_t
 *    %p                        void *
 *    %[x|X]V                   ngx_str_t *
 *    %[x|X]v                   ngx_variable_value_t *
 *    %[x|X]s                   null-terminated string
 *    %*[x|X]s                  length and string
 *    %Z                        '\0'
 *    %N                        '\n'
 *    %c                        char
 *    %%                        %
 *
 *  reserved:
 *    %t                        ptrdiff_t
 *    %S                        null-terminated wchar string
 *    %C                        wchar
 */