PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/System Design/Qube Research & Technologies

Design an asynchronous logger with formatting

Last updated: Mar 29, 2026

Quick Overview

This question evaluates expertise in concurrent programming, lock-free MPMC queue usage, producer–consumer asynchronous logging, variadic formatting APIs, and robustness in shutdown/flush semantics and error handling.

  • hard
  • Qube Research & Technologies
  • System Design
  • Software Engineer

Design an asynchronous logger with formatting

Company: Qube Research & Technologies

Role: Software Engineer

Category: System Design

Difficulty: hard

Interview Round: Technical Screen

Design and implement an asynchronous C++ logger that accepts variadic arguments with fmt-style format strings, uses a background thread to perform formatting and writing, and passes messages via a provided lock-free queue. Assume we do not optimize for heap usage or memory footprint. Specify the public API, the log event structure, the producer–consumer flow, and demonstrate shutdown/flush behavior and error handling.

Quick Answer: This question evaluates expertise in concurrent programming, lock-free MPMC queue usage, producer–consumer asynchronous logging, variadic formatting APIs, and robustness in shutdown/flush semantics and error handling.

Qube Research & Technologies logo
Qube Research & Technologies
Sep 6, 2025, 12:00 AM
Software Engineer
Technical Screen
System Design
5
0

Design an Asynchronous C++ Logger Using a Lock-Free Queue

Context

You are asked to design and implement an asynchronous logger suitable for a technical screen in a systems/engineering interview. The logger must:

  • Accept variadic arguments using fmt-style format strings.
  • Use a background thread to perform formatting and writing.
  • Pass log events through a provided lock-free queue.
  • Not optimize for heap usage or memory footprint (allocations are acceptable).

Assume a generic lock-free MPMC queue is provided with a minimal try_enqueue/try_dequeue API. You should:

  • Specify the public API.
  • Define the log event structure.
  • Describe the producer–consumer flow.
  • Demonstrate shutdown/flush behavior.
  • Describe error handling and overflow policy.

Requirements

  1. Public API that supports:
    • Variadic, fmt-style logging (compile-time format checking preferred).
    • Flush and shutdown semantics.
    • Configurable sink (e.g., file or stderr) and error handling hooks.
  2. Log events must be enqueued by producers and formatted/written by a background consumer thread.
  3. Messages should be passed as events through the lock-free queue; formatting happens only on the consumer side.
  4. Show robust shutdown/flush that drains the queue and avoids message loss.
  5. Explain error handling (enqueue overflow, formatting errors, I/O failures).

Solution

Show

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More System Design•More Qube Research & Technologies•More Software Engineer•Qube Research & Technologies Software Engineer•Qube Research & Technologies System Design•Software Engineer System Design
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.