LMMS / LMMS/lmms

Requirements for a Logging class

Open
#5,825 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
10.4k
Forks
1.3k
Avg merge
2d 13h
Merged PRs (30d)
7

Description

## Statements

This is just a summary of what a logger must/must not do, along with justifications. Feel free to comment if you think some points are not appropriate.

1. **A logger must be able to print to console**
Otherwise, no one notes critical issues
2. **Logging must not have race conditions**
Follows from 1: We have only 1 console and multiple threads who may have (critical) messages. Stuff like `hello, I'm the reahello I'm the non-realtime thread!ltime thread!` should be avoided. Also, multiple non-RT (non realtime) threads should not write into the same file at the same time.
3. **We need possibility to log in RT (realtime/audio) threads**: Imagine critical warnings about floating point issues, values too low, too high etc. These can sometimes only be emitted from the RT thread. This must be logged.
4. **RT thread in release mode must be able to do RT safe logging** because otherwise
1. every log there will look like
```
#ifdef RT_DEBUG
// log stuff non-RT-safe, e.g. with qDebug()
#endif
```
which is 3 ugly lines no one wants to read or write.
2. it's difficult to write debug output in classes which are accessed from both RT and non-RT.
3. regular users with release-build will never see critical issues, and thus we will get less (or less useful) bug reports.
5. **QDebug can not be used RT-safe** (same for `std::cout` or `printf`)
It has a `QDebug::operator<<` for ints, floats, etc, which forwards to its internal `QTextStream`, which uses a `QString`. This is very likely not RT safe. We could inherit `QDebug`, but I guess that's not how its being done. If we inherit it just to completely rewrite it, then we don't need to inherit it at all...
6. **QDebug** can not be used at all
Follows from 4+5, and 2 (the fact that we can not use our logger while QDebug() prints to console).

## Conclusion/Summary

1. We need our self-written logging class.
2. Logging in RT thread is required
3. In case it's used by the RT thread (the logger can find that out), it must send it to a ringbuffer of the non-RT thread.
4. The whole output stuff on the non-RT side must be mutexed.

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue names no files, tests, or entry points. Start by mapping the existing logging paths and the realtime and non-realtime thread boundaries, then compare them with the listed requirements. Done would mean a self-written logger that supports realtime-safe logging through a ring buffer and mutexed non-realtime output.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
observability-sre
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.