
Show HN: Nanosecond C message logger - RafaGC
Hello,<p>Some time ago I did a data logger for fun, just to check if I could beat the performance
of an old C++ project of mine (mini-async-log) and to avoid letting my multithreading-C
skills rust when on a non-programming gig (using Yocto&#x2F;OE, very little programming).<p>This project is a BSD licensed, producer-wait-free (when using thread-local storage) generic
message logger with high performance, decent test coverage, and type-safe C
strings (requires C11 or C++ compiler).<p>It was a shame to let this project to die unknown, as I think that it has
potential to be used on some niches as network programs, HFT, games, etc. so
here I am sharing it.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;RafaGago&#x2F;mini-async-log" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;RafaGago&#x2F;mini-async-log</a><p>This was an evolution of a similar logger I did, this time I wanted to achieve wait-free
producers, so this implementation can use thread-local storage to achieve that. Some other
non allocation-free strategies are also available.<p>I still aimed for as easy as possible usage&#x2F;learning curve and maintenance vs
lots of features.<p>It has some interesting things too:<p>-It has one modification on Djukov&#x27;s MPMC queue to make it MPSC and accepting
variable (but limited) bucket size allocations (at the expense of unfairness
towards bigger buckets). There are more modifications&#x2F;variations on this
Djukov queue on the library where I&#x27;m collecting all the generic stuff that I
use when developing C programs.<p>-The project still maintains automatic type detection of the string formatters
by using &quot;clever&quot; hardcore C preprocessor abuse mixed with C11 type-generic
expressions. It still accepts most non-type printf modifiers. This is at the
same time beautiful and ugly (you know what I mean), for the uglyness part,
automated testing is available.<p>NOTE: Untested on Windows.
======
dinglejungle
You seemed to have linked to the C++ version only.

The C repo: [https://github.com/RafaGago/mini-async-
log-c](https://github.com/RafaGago/mini-async-log-c)

~~~
RafaGC
Thank you. It's a shame that I can't edit the original post.

------
shereadsthenews
looking at your benchmarks, I see that you think glog is synchronous. This
would be because you are logging at ERROR severity which does indeed flush.
Logging at INFO would not have that issue.

~~~
RafaGC
Oh, I wasn't aware of that.

------
vkaku
Good effort;

It's not just enough to have fast logging, it is also required to not abuse
logging by having long, too many or useless messages.

Most people need a guide for 'The art of the log'. They should also know 'The
art of the counters.'

~~~
iampims
Here’s a good post about it: [https://dave.cheney.net/2015/11/05/lets-talk-
about-logging](https://dave.cheney.net/2015/11/05/lets-talk-about-logging)

------
alecco
Can you expand a bit? What do you mean by nanosecond? (1,10,100?)

~~~
a1369209993
My first thought was "Thirty centimeters seems a bit large for a message
logger.".

