Microseconds to error log
Personne n'a encore pris cette issue.
- Langage dominant
- C
- Étoiles
- 40.4k
- Forks
- 8.1k
- Merge moyen
- 2 j 13 h
- PR mergées (30 j)
- 96
Description
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)?
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par lire php_log_err_with_severity() dans main/main.c et le code de formatage des dates dans ext/date/php_date.c. Comparez les approches disponibles décrites dans l’issue et déterminez quelle API ou quel design upstream est acceptable sans casser les appelants existants. C’est terminé lorsque le périmètre et la voie d’implémentation des horodatages de journal d’erreurs à la microseconde sont convenus et exploitables.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- c, php
- Domaine
- backend
- Type d'issue
- Fonctionnalité
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 25/100