Do you mean only once during the entire execution of the program, or will you ever have a reset criterion that allows it to be displayed again? In any case, I recommend creating a wrapper class that you create as a field with a built-in bool flag for each particular line that you want to display only "once." If the line is known as fixed (without parameters that change it), you can also use the central service class, which stores a set of lines that have already been printed. The problem is that you cannot register the same line from multiple places.
One general general solution is the "alarm manager", although I have not seen a standardized library for this. However, this often occurs in my industry, because industrial equipment can enter a state of constant alarm, and you want to register transitions to an alarm state, but you do not constantly register that you are still in an alarm state. The solutions I used / saw usually create a unique alarm code for each condition with the concepts of "set" and "clear", often with the intervention of the operator, necessary to confirm and finally eliminate the alarm.
source share