File tree 4 files changed +54
-1
lines changed
4 files changed +54
-1
lines changed Original file line number Diff line number Diff line change 19
19
import warnings
20
20
from typing import Any
21
21
22
+ import gitlab ._logging
22
23
import gitlab .config # noqa: F401
23
24
from gitlab import utils as _utils
24
25
from gitlab ._version import ( # noqa: F401
Original file line number Diff line number Diff line change
1
+ # -*- coding: utf-8 -*-
2
+
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU Lesser General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public License
14
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ import logging
17
+ from typing import List
18
+
19
+ __all__ : List [str ] = []
20
+
21
+ # Using the `NullHandler` means that any log messages generated will not be
22
+ # output unless the client application configures logging. For example by
23
+ # calling `logging.basicConfig()`
24
+ _module_root_logger_name = __name__ .split ("." , maxsplit = 1 )[0 ]
25
+ logging .getLogger (_module_root_logger_name ).addHandler (logging .NullHandler ())
Original file line number Diff line number Diff line change 16
16
# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
"""Wrapper for the GitLab API."""
18
18
19
+ import logging
19
20
import os
20
21
import re
21
22
import time
32
33
import gitlab .exceptions
33
34
from gitlab import utils
34
35
36
+ LOG = logging .getLogger (__name__ )
37
+
35
38
REDIRECT_MSG = (
36
39
"python-gitlab detected a {status_code} ({reason!r}) redirection. You must update "
37
40
"your GitLab URL to the correct URL to avoid issues. The redirection was from: "
@@ -536,7 +539,6 @@ def _set_auth_info(self) -> None:
536
539
537
540
@staticmethod
538
541
def enable_debug () -> None :
539
- import logging
540
542
from http .client import HTTPConnection # noqa
541
543
542
544
HTTPConnection .debuglevel = 1
@@ -545,6 +547,7 @@ def enable_debug() -> None:
545
547
requests_log = logging .getLogger ("requests.packages.urllib3" )
546
548
requests_log .setLevel (logging .DEBUG )
547
549
requests_log .propagate = True
550
+ LOG .debug ("Enabled debug mode for python-gitlab" )
548
551
549
552
def _get_session_opts (self ) -> Dict [str , Any ]:
550
553
return {
Original file line number Diff line number Diff line change
1
+ import logging
2
+
3
+ import pytest
4
+
5
+ from gitlab import _logging
6
+
7
+
8
+ @pytest .fixture
9
+ def LOG ():
10
+ return logging .getLogger (_logging ._module_root_logger_name )
11
+
12
+
13
+ def test_module_root_logger_name ():
14
+ assert _logging ._module_root_logger_name == "gitlab"
15
+
16
+
17
+ def test_module_name (LOG ):
18
+ assert LOG .name == "gitlab"
19
+
20
+
21
+ def test_logger_null_handler (LOG ):
22
+ assert len (LOG .handlers ) == 1
23
+ handler = LOG .handlers [0 ]
24
+ assert isinstance (handler , logging .NullHandler )
You can’t perform that action at this time.
0 commit comments