1
- # standard library
2
1
import logging
3
2
import time
4
3
from datetime import datetime
5
4
6
5
from mkdocs_git_revision_date_localized_plugin .ci import raise_ci_warnings
7
6
8
- # 3rd party
9
7
from babel .dates import format_date , get_timezone
10
8
from git import Repo , GitCommandError , GitCommandNotFound
11
9
10
+ logger = logging .getLogger ("mkdocs.plugins" )
12
11
13
12
class Util :
14
13
def __init__ (self , path : str = "." , config = {}):
@@ -21,13 +20,13 @@ def __init__(self, path: str = ".", config={}):
21
20
except :
22
21
if config .get ("fallback_to_build_date" ):
23
22
self .fallback_enabled = True
24
- logging .warning (
23
+ logger .warning (
25
24
"[git-revision-date-localized-plugin] Unable to find a git directory and/or git is not installed."
26
25
" Option 'fallback_to_build_date' set to 'true': Falling back to build date"
27
26
)
28
27
return None
29
28
else :
30
- logging .error (
29
+ logger .error (
31
30
"[git-revision-date-localized-plugin] Unable to find a git directory and/or git is not installed."
32
31
" To ignore this error, set option 'fallback_to_build_date: true'"
33
32
)
@@ -98,26 +97,26 @@ def get_revision_date_for_file(
98
97
99
98
except GitCommandError as err :
100
99
if fallback_to_build_date :
101
- logging .warning (
100
+ logger .warning (
102
101
"[git-revision-date-localized-plugin] Unable to read git logs of '%s'. Is git log readable?"
103
102
" Option 'fallback_to_build_date' set to 'true': Falling back to build date"
104
103
% path
105
104
)
106
105
else :
107
- logging .error (
106
+ logger .error (
108
107
"[git-revision-date-localized-plugin] Unable to read git logs of '%s'. "
109
108
" To ignore this error, set option 'fallback_to_build_date: true'"
110
109
% path
111
110
)
112
111
raise err
113
112
except GitCommandNotFound as err :
114
113
if fallback_to_build_date :
115
- logging .warning (
114
+ logger .warning (
116
115
"[git-revision-date-localized-plugin] Unable to perform command: 'git log'. Is git installed?"
117
116
" Option 'fallback_to_build_date' set to 'true': Falling back to build date"
118
117
)
119
118
else :
120
- logging .error (
119
+ logger .error (
121
120
"[git-revision-date-localized-plugin] Unable to perform command 'git log'. Is git installed?"
122
121
" To ignore this error, set option 'fallback_to_build_date: true'"
123
122
)
@@ -127,7 +126,7 @@ def get_revision_date_for_file(
127
126
if not unix_timestamp :
128
127
unix_timestamp = time .time ()
129
128
if not self .fallback_enabled :
130
- logging .warning (
129
+ logger .warning (
131
130
"[git-revision-date-localized-plugin] '%s' has no git logs, using current timestamp"
132
131
% path
133
132
)
0 commit comments