-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use logger instead of prints/warnings
- Loading branch information
Showing
4 changed files
with
66 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import os | ||
import logging | ||
from tempfile import gettempdir | ||
|
||
from typing import Optional | ||
|
||
from logzero import setup_logger # type: ignore[import] | ||
|
||
DEFAULT_LEVEL = logging.INFO | ||
|
||
logpath = os.path.join(gettempdir(), "calcurse_load.log") | ||
|
||
|
||
# logzero handles adding handling/modifying levels fine | ||
# can be imported/configured multiple times | ||
def setup(level: Optional[int] = None) -> logging.Logger: | ||
chosen_level = level or int(os.environ.get("CALCURSE_LOAD_LOGS", DEFAULT_LEVEL)) | ||
lgr: logging.Logger = setup_logger( | ||
name=__package__, level=chosen_level, disableStderrLogger=True, logfile=logpath | ||
) | ||
return lgr | ||
|
||
|
||
logger = setup() |