helpers: logging: add warn_once() (MR 2344)

Add a warn_once() function using Cache. Since we use f-strings
everywhere we don't really need the varargs.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-07-02 14:08:48 +02:00
parent a57b338e9e
commit 55c912d410
No known key found for this signature in database
GPG key ID: 0583312B195F64B6

View file

@ -6,6 +6,7 @@ from pathlib import Path
import sys
from typing import TextIO
import pmb.config
from pmb.meta import Cache
logfd: TextIO
@ -177,6 +178,10 @@ def warning(msg: object, *args, **kwargs):
logging.warning(msg, *args, **kwargs)
@Cache("msg")
def warn_once(msg: str):
logging.warning(msg)
def info(msg: object, *args, **kwargs):
logging.info(msg, *args, **kwargs)