1- # standard library
21import logging
32import time
43from datetime import datetime
54
65from mkdocs_git_revision_date_localized_plugin .ci import raise_ci_warnings
76
8- # 3rd party
97from babel .dates import format_date , get_timezone
108from git import Repo , GitCommandError , GitCommandNotFound
119
10+ logger = logging .getLogger ("mkdocs.plugins" )
1211
1312class 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