Asynchronous error_logger:error_msg considered harmful?

Olivier BOUDEVILLE <>
Fri Sep 17 17:39:23 CEST 2010


Hello,

When displaying a message with error_logger:error_msg/2, apparently this 
is done asynchronously, the call returns before the message is actually 
displayed in the console. 
As a result, if in the next few instructions the VM is halted (these two 
events must be often correlated), there is a race condition between the 
displaying and the halting: sometimes the message shows up, sometimes not.

Short of knowing a better solution, this was one of the very few places 
where a timer:sleep/1 call helped me, despite this is never a satisfying 
solution. And indeed it led to hiding a second race condition, this time 
in my code, which was difficult to track because of this awkward delay.

Apparently there could be a better solution based on the use of 
sys:get_status(error_logger) which could allow to wait just the duration 
needed until the operation is done, thus allowing somewhat to emulate a 
synchronous error_logger:error_msg/2 (I have not figured out yet out to 
use it properly).

I was wanting to advertise a bit this solution as it seems not very 
well-known. Besides, for error messages, wouldn't it be safer to be 
synchronous at the first place?

Best regards,

Olivier Boudeville.
---------------------------
Olivier Boudeville

EDF R&D : 1, avenue du Général de Gaulle, 92140 Clamart, France
Département SINETICS, groupe ASICS (I2A), bureau B-226
Office : +33 1 47 65 59 58 / Mobile : +33 6 16 83 37 22 / Fax : +33 1 47 
65 27 13



Ce message et toutes les pièces jointes (ci-après le 'Message') sont établis à l'intention exclusive des destinataires et les informations qui y figurent sont strictement confidentielles. Toute utilisation de ce Message non conforme à sa destination, toute diffusion ou toute publication totale ou partielle, est interdite sauf autorisation expresse.

Si vous n'êtes pas le destinataire de ce Message, il vous est interdit de le copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si vous avez reçu ce Message par erreur, merci de le supprimer de votre système, ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support que ce soit. Nous vous remercions également d'en avertir immédiatement l'expéditeur par retour du message.

Il est impossible de garantir que les communications par messagerie électronique arrivent en temps utile, sont sécurisées ou dénuées de toute erreur ou virus.
____________________________________________________

This message and any attachments (the 'Message') are intended solely for the addressees. The information contained in this Message is confidential. Any use of information contained in this Message not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval.

If you are not the addressee, you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return message.

E-mail communication cannot be guaranteed to be timely secure, error or virus-free.


More information about the erlang-questions mailing list