[erlang-questions] logging from linked-in drivers
Mon Sep 26 22:30:13 CEST 2011
> Yeah, this is what I do with debugging statements. I'd like to put
> individual log lines/entries out to the file system rather than the console.
> Given that posix requires stdio operations dealing with FILE* structures to
> work atomically, do you think fprintf calls are a reasonable thing to do in
> a multi-threaded driver?.
This seems like an inane question. What I'm getting at is that I've seen
plenty of driver code which writes to a file like this only when protected
by a driver mutex. I'm guessing that this is because they are pushing
multiple lines/writes out in one go and want to avoid interleaving the
output when many threads simultaneously call the write/log function.
Now I don't care about this interleaving as all my logging statements fit in
a single (s)printf call and I couldn't care less about the order in which
they appear in the log - the thread id is there to disseminate this
information later on. I'm under the impression that posix compliant systems
will ensure that the single write (and therefore individual log lines) are
written atomically. Have I got this right and is this is reasonable
assumption to make - it feels like no, but I'm being over cautious as I
don't know the answer and don't want to write useless driver code. I'd also
like to avoid excessive locking if it's not necessary and certainly avoid
excessive communication between the driver and the emulator just for
Can anyone clear this up for me? Is there a Right Thing To Do (TM) in this
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions