Microseconds to error log
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C
- Star
- 40.4k
- Fork
- 8.2k
- Merge trung bình
- 2 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 96
Mô tả
Description
Hi there,
Not sure if this is the right place to discuss the topic. Please, guide me to the proper place if this needs to be re-directed.
We have quite a high-loaded environment and we really want to see timestamps containing microseconds in our logs. It is easy to do for our custom logger but error messages from the PHP itself narrowed down to seconds (I'm talking about method php_log_err_with_severity()
In our repository, we have a hacky patch that adds microsecs in this log as well. Unfortunately, such a solution is not really a good approach to looking into the future.
I wanted to adopt our patch to share it with the community and potentially merge it into upstream but stumbled upon the fact that it isn't really straightforward to format a date with microseconds using the standard API available for an extension.
Basically, I found a couple of options:
-
We can instantiate a DateTime object and call
DateTime::format(). It looks working but it makes the logging function way more complicated and potentially heavy -
date_formatworks directly withtimelib_timeand can properly handle microsecs but it is hidden insideext/date/php_date.c, Not really sure if it's a good idea to make it public -
In theory, it is possible to add one more parameter to
php_format_datebut it'll break all the existing code. The change of signature doesn't look like a good option. However, we might be able to introduce another function if we want to encapsulate work withtimelib_timewithin theext/date.
Looking into the future, probably we would like to have this format configurable, if so it looks easy to do but still I can't see an easy way to handle the microseconds issue.
Could you please help me to find the right way and share your thoughts about this topic (maybe there are strong objections against such a change)?
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách đọc php_log_err_with_severity() trong main/main.c và mã định dạng ngày tháng trong ext/date/php_date.c. So sánh các cách tiếp cận hiện có được mô tả trong issue và xác định API hoặc thiết kế upstream nào là chấp nhận được mà không làm hỏng các caller hiện tại. Được xem là hoàn tất khi phạm vi và hướng triển khai cho timestamp log lỗi ở độ phân giải microsecond đã được thống nhất và có thể thực hiện.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- c, php
- Lĩnh vực
- backend
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 25/100