mit-dci / opencbdc-tx

A transaction processor for a hypothetical, general-purpose, central bank digital currency
Other
895 stars 200 forks source link

logger::fatal(...) terminates the program - investigate alternatives #219

Open AlexRamRam opened 1 year ago

AlexRamRam commented 1 year ago

Affected Branch

trunk

Basic Diagnostics

Description

It's surprising to a reader that the logger object has the power to terminate the program when fatal() is called.

Consider these alternatives to improve code clarity:

Code of Conduct

AlexRamRam commented 10 months ago

Use of the "fatal" interface for a logging mechanism (to log then system exist) may be a common convention. Golang is one (significant) example:

From a personal experience, I do think something like fatal_system_exit() would provide better clarity. However, there is a strong argument to close this issue item if fatal is a well-known convention.

@HalosGhost I will leave the decision of closing this item up to you.

HalosGhost commented 10 months ago

It's not an unheard-of idiom. But, I've never found it well-structured from a separation-of-concerns perspective (seems odd to me that the logger should really be able to control whether execution continues). I'm not particularly certain there's a better plan without rearchitecting a lot of code (this is one of those small implementation detail decisions that has far-reaching effects if you change it because it violates basic separation-of-concerns).

So, I'm comfortable with this being closed, being fixed by a rename, or proposals for something better.