Writing a Go logger

Home » Writing a Go logger

Writing a Go logger

ABSTRACT

Have you ever thought about writing a logger instead of using the one in the std library?
Let’s code an idiomatic logger that supports tracing and other custom behaviors out of the box maintaining blazing fast and simple APIs by using benchmarks and profiling as the foundation for our decisions.

DESCRIPTION

Writing a logger can be tricky and performance issues are hidden and tricky to find.
Since I wrote a logger in Go, I want to share the knowledge I gained out of that by coding a session (inspired by the open-source one I wrote) to show bottlenecks from a performance and design perspective.
The deep dive will be in writing benchmarks for encoding the log entry and profiling the whole logger design to determine where it could be improved.

WORKSHOP AGENDA

– Define idiomatic APIs for the logger;
– Implement a logger based on the previously defined APIs;
– Measure performance benchmarking the logger implementation;
– Improve performances by switching to a hand-written JSON encoder.

WHAT WILL WE LEARN?

– Learn to define idiomatic Go APIs;
– Learn the implementation details of a concurrent-safe and fast logger;
– Learn to benchmark and profile your code and compare it to other already existing implementations;
– Learn to write a faster JSON encoder.

TECHNICAL PREREQUISITES

One laptop with Go >= 1.18 installed.

Damiano Petrungaro

Tech Lead
Pento

Philosopher ego-less tech lead, speaker, open-source maintainer, mentor, and community enthusiast.
I am specialized in working with Golang and PHP applications using domain-driven design (DDD) and test-driven development (TDD) methodologies supported by modern tools and practices such as Docker, CI/CD, and SRE.
At the moment I am focused on coding complex domain logic and writing clean and testable code, with a massive focus on performance and developer experience.
Along with software skills, I have experience in managing teams and people, improving team processes & technologies, and setting up ambitious & SMART goals.

Expert in: PHP, Go

Follow us