Skip to content

Commit 84d3bbc

Browse files
committed
improve formatting of logging.warning to be consistent with mkdocs
1 parent c87530c commit 84d3bbc

File tree

1 file changed

+8
-9
lines changed
  • mkdocs_git_revision_date_localized_plugin

1 file changed

+8
-9
lines changed

mkdocs_git_revision_date_localized_plugin/util.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
# standard library
21
import logging
32
import time
43
from datetime import datetime
54

65
from mkdocs_git_revision_date_localized_plugin.ci import raise_ci_warnings
76

8-
# 3rd party
97
from babel.dates import format_date, get_timezone
108
from git import Repo, GitCommandError, GitCommandNotFound
119

10+
logger = logging.getLogger("mkdocs.plugins")
1211

1312
class Util:
1413
def __init__(self, path: str = ".", config={}):
@@ -21,13 +20,13 @@ def __init__(self, path: str = ".", config={}):
2120
except:
2221
if config.get("fallback_to_build_date"):
2322
self.fallback_enabled = True
24-
logging.warning(
23+
logger.warning(
2524
"[git-revision-date-localized-plugin] Unable to find a git directory and/or git is not installed."
2625
" Option 'fallback_to_build_date' set to 'true': Falling back to build date"
2726
)
2827
return None
2928
else:
30-
logging.error(
29+
logger.error(
3130
"[git-revision-date-localized-plugin] Unable to find a git directory and/or git is not installed."
3231
" To ignore this error, set option 'fallback_to_build_date: true'"
3332
)
@@ -98,26 +97,26 @@ def get_revision_date_for_file(
9897

9998
except GitCommandError as err:
10099
if fallback_to_build_date:
101-
logging.warning(
100+
logger.warning(
102101
"[git-revision-date-localized-plugin] Unable to read git logs of '%s'. Is git log readable?"
103102
" Option 'fallback_to_build_date' set to 'true': Falling back to build date"
104103
% path
105104
)
106105
else:
107-
logging.error(
106+
logger.error(
108107
"[git-revision-date-localized-plugin] Unable to read git logs of '%s'. "
109108
" To ignore this error, set option 'fallback_to_build_date: true'"
110109
% path
111110
)
112111
raise err
113112
except GitCommandNotFound as err:
114113
if fallback_to_build_date:
115-
logging.warning(
114+
logger.warning(
116115
"[git-revision-date-localized-plugin] Unable to perform command: 'git log'. Is git installed?"
117116
" Option 'fallback_to_build_date' set to 'true': Falling back to build date"
118117
)
119118
else:
120-
logging.error(
119+
logger.error(
121120
"[git-revision-date-localized-plugin] Unable to perform command 'git log'. Is git installed?"
122121
" To ignore this error, set option 'fallback_to_build_date: true'"
123122
)
@@ -127,7 +126,7 @@ def get_revision_date_for_file(
127126
if not unix_timestamp:
128127
unix_timestamp = time.time()
129128
if not self.fallback_enabled:
130-
logging.warning(
129+
logger.warning(
131130
"[git-revision-date-localized-plugin] '%s' has no git logs, using current timestamp"
132131
% path
133132
)

0 commit comments

Comments
 (0)