|
4 | 4 | import java.util.Map;
|
5 | 5 | import java.util.Optional;
|
6 | 6 | import java.util.WeakHashMap;
|
| 7 | +import java.util.logging.Level; |
7 | 8 | import java.util.logging.Logger;
|
8 | 9 |
|
9 | 10 | import javax.ws.rs.core.MediaType;
|
|
23 | 24 | */
|
24 | 25 | public class GitLabApi {
|
25 | 26 |
|
26 |
| - private final static Logger LOG = Logger.getLogger(GitLabApi.class.getName()); |
| 27 | + private final static Logger LOGGER = Logger.getLogger(GitLabApi.class.getName()); |
27 | 28 |
|
28 | 29 | /** GitLab4J default per page. GitLab will ignore anything over 100. */
|
29 | 30 | public static final int DEFAULT_PER_PAGE = 100;
|
@@ -85,7 +86,7 @@ public String getApiNamespace() {
|
85 | 86 | * @return the GitLab4J shared Logger instance
|
86 | 87 | */
|
87 | 88 | public static final Logger getLogger() {
|
88 |
| - return (LOG); |
| 89 | + return (LOGGER); |
89 | 90 | }
|
90 | 91 |
|
91 | 92 | /**
|
@@ -638,6 +639,69 @@ public GitLabApi(ApiVersion apiVersion, String hostUrl, TokenType tokenType, Str
|
638 | 639 | apiClient = new GitLabApiClient(apiVersion, hostUrl, tokenType, authToken, secretToken, clientConfigProperties);
|
639 | 640 | }
|
640 | 641 |
|
| 642 | + /** |
| 643 | + * Enable the logging of the requests to and the responses from the GitLab server API |
| 644 | + * using the GitLab4J shared Logger instance and Level.FINE as the level. |
| 645 | + * |
| 646 | + * @return this GitLabApi instance |
| 647 | + */ |
| 648 | + public GitLabApi withRequestResponseLogging() { |
| 649 | + enableRequestResponseLogging(); |
| 650 | + return (this); |
| 651 | + } |
| 652 | + |
| 653 | + /** |
| 654 | + * Enable the logging of the requests to and the responses from the GitLab server API |
| 655 | + * using the GitLab4J shared Logger instance. |
| 656 | + * |
| 657 | + * @param level the logging level (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST) |
| 658 | + * @return this GitLabApi instance |
| 659 | + */ |
| 660 | + public GitLabApi withRequestResponseLogging(Level level) { |
| 661 | + enableRequestResponseLogging(level); |
| 662 | + return (this); |
| 663 | + } |
| 664 | + |
| 665 | + /** |
| 666 | + * Enable the logging of the requests to and the responses from the GitLab server API. |
| 667 | + * |
| 668 | + * @param logger the Logger instance to log to |
| 669 | + * @param level the logging level (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST) |
| 670 | + * @return this GitLabApi instance |
| 671 | + */ |
| 672 | + public GitLabApi withRequestResponseLogging(Logger logger, Level level) { |
| 673 | + enableRequestResponseLogging(logger, level); |
| 674 | + return (this); |
| 675 | + } |
| 676 | + |
| 677 | + /** |
| 678 | + * Enable the logging of the requests to and the responses from the GitLab server API |
| 679 | + * using the GitLab4J shared Logger instance and Level.FINE as the level. |
| 680 | + */ |
| 681 | + public void enableRequestResponseLogging() { |
| 682 | + enableRequestResponseLogging(LOGGER, Level.FINE); |
| 683 | + } |
| 684 | + |
| 685 | + /** |
| 686 | + * Enable the logging of the requests to and the responses from the GitLab server API |
| 687 | + * using the GitLab4J shared Logger instance. |
| 688 | + * |
| 689 | + * @param level the logging level (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST) |
| 690 | + */ |
| 691 | + public void enableRequestResponseLogging(Level level) { |
| 692 | + enableRequestResponseLogging(LOGGER, level); |
| 693 | + } |
| 694 | + |
| 695 | + /** |
| 696 | + * Enable the logging of the requests to and the responses from the GitLab server API. |
| 697 | + * |
| 698 | + * @param logger the Logger instance to log to |
| 699 | + * @param level the logging level (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST) |
| 700 | + */ |
| 701 | + public void enableRequestResponseLogging(Logger logger, Level level) { |
| 702 | + this.apiClient.enableRequestResponseLogging(logger, level); |
| 703 | + } |
| 704 | + |
641 | 705 | /**
|
642 | 706 | * Sets up all future calls to the GitLab API to be done as another user specified by sudoAsUsername.
|
643 | 707 | * To revert back to normal non-sudo operation you must call unsudo(), or pass null as the username.
|
@@ -1413,5 +1477,4 @@ public WikisApi getWikisApi() {
|
1413 | 1477 |
|
1414 | 1478 | return wikisApi;
|
1415 | 1479 | }
|
1416 |
| - |
1417 | 1480 | }
|
0 commit comments