|
1 | 1 | package org.gitlab4j.api;
|
2 | 2 |
|
3 | 3 | import java.util.Collections;
|
| 4 | +import java.util.List; |
4 | 5 | import java.util.Map;
|
5 | 6 | import java.util.Optional;
|
6 | 7 | import java.util.WeakHashMap;
|
|
15 | 16 | import org.gitlab4j.api.models.Session;
|
16 | 17 | import org.gitlab4j.api.models.User;
|
17 | 18 | import org.gitlab4j.api.models.Version;
|
| 19 | +import org.gitlab4j.api.utils.MaskingLoggingFilter; |
18 | 20 | import org.gitlab4j.api.utils.Oauth2LoginStreamingOutput;
|
19 | 21 | import org.gitlab4j.api.utils.SecretString;
|
20 | 22 |
|
@@ -618,22 +620,104 @@ public void enableRequestResponseLogging() {
|
618 | 620 |
|
619 | 621 | /**
|
620 | 622 | * Enable the logging of the requests to and the responses from the GitLab server API
|
621 |
| - * using the GitLab4J shared Logger instance. |
| 623 | + * using the GitLab4J shared Logger instance. Logging will NOT include entity logging and |
| 624 | + * will mask PRIVATE-TOKEN and Authorization headers. |
622 | 625 | *
|
623 | 626 | * @param level the logging level (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST)
|
624 | 627 | */
|
625 | 628 | public void enableRequestResponseLogging(Level level) {
|
626 |
| - enableRequestResponseLogging(LOGGER, level); |
| 629 | + enableRequestResponseLogging(LOGGER, level, 0); |
627 | 630 | }
|
628 | 631 |
|
629 | 632 | /**
|
630 |
| - * Enable the logging of the requests to and the responses from the GitLab server API. |
| 633 | + * Enable the logging of the requests to and the responses from the GitLab server API using the |
| 634 | + * specified logger. Logging will NOT include entity logging and will mask PRIVATE-TOKEN |
| 635 | + * and Authorization headers.. |
631 | 636 | *
|
632 | 637 | * @param logger the Logger instance to log to
|
633 | 638 | * @param level the logging level (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST)
|
634 | 639 | */
|
635 | 640 | public void enableRequestResponseLogging(Logger logger, Level level) {
|
636 |
| - this.apiClient.enableRequestResponseLogging(logger, level); |
| 641 | + enableRequestResponseLogging(logger, level, 0); |
| 642 | + } |
| 643 | + |
| 644 | + /** |
| 645 | + * Enable the logging of the requests to and the responses from the GitLab server API using the |
| 646 | + * GitLab4J shared Logger instance. Logging will mask PRIVATE-TOKEN and Authorization headers. |
| 647 | + * |
| 648 | + * @param level the logging level (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST) |
| 649 | + * @param maxEntitySize maximum number of entity bytes to be logged. When logging if the maxEntitySize |
| 650 | + * is reached, the entity logging will be truncated at maxEntitySize and "...more..." will be added at |
| 651 | + * the end of the log entry. If maxEntitySize is <= 0, entity logging will be disabled |
| 652 | + */ |
| 653 | + public void enableRequestResponseLogging(Level level, int maxEntitySize) { |
| 654 | + enableRequestResponseLogging(LOGGER, level, maxEntitySize); |
| 655 | + } |
| 656 | + |
| 657 | + /** |
| 658 | + * Enable the logging of the requests to and the responses from the GitLab server API using the |
| 659 | + * specified logger. Logging will mask PRIVATE-TOKEN and Authorization headers. |
| 660 | + * |
| 661 | + * @param logger the Logger instance to log to |
| 662 | + * @param level the logging level (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST) |
| 663 | + * @param maxEntitySize maximum number of entity bytes to be logged. When logging if the maxEntitySize |
| 664 | + * is reached, the entity logging will be truncated at maxEntitySize and "...more..." will be added at |
| 665 | + * the end of the log entry. If maxEntitySize is <= 0, entity logging will be disabled |
| 666 | + */ |
| 667 | + public void enableRequestResponseLogging(Logger logger, Level level, int maxEntitySize) { |
| 668 | + enableRequestResponseLogging(logger, level, maxEntitySize, MaskingLoggingFilter.DEFAULT_MASKED_HEADER_NAMES); |
| 669 | + } |
| 670 | + |
| 671 | + /** |
| 672 | + * Enable the logging of the requests to and the responses from the GitLab server API using the |
| 673 | + * GitLab4J shared Logger instance. |
| 674 | + * |
| 675 | + * @param level the logging level (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST) |
| 676 | + * @param maskedHeaderNames a list of header names that should have the values masked |
| 677 | + */ |
| 678 | + public void enableRequestResponseLogging(Level level, List<String> maskedHeaderNames) { |
| 679 | + apiClient.enableRequestResponseLogging(LOGGER, level, 0, maskedHeaderNames); |
| 680 | + } |
| 681 | + |
| 682 | + /** |
| 683 | + * Enable the logging of the requests to and the responses from the GitLab server API using the |
| 684 | + * specified logger. |
| 685 | + * |
| 686 | + * @param logger the Logger instance to log to |
| 687 | + * @param level the logging level (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST) |
| 688 | + * @param maskedHeaderNames a list of header names that should have the values masked |
| 689 | + */ |
| 690 | + public void enableRequestResponseLogging(Logger logger, Level level, List<String> maskedHeaderNames) { |
| 691 | + apiClient.enableRequestResponseLogging(logger, level, 0, maskedHeaderNames); |
| 692 | + } |
| 693 | + |
| 694 | + /** |
| 695 | + * Enable the logging of the requests to and the responses from the GitLab server API using the |
| 696 | + * GitLab4J shared Logger instance. |
| 697 | + * |
| 698 | + * @param level the logging level (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST) |
| 699 | + * @param maxEntitySize maximum number of entity bytes to be logged. When logging if the maxEntitySize |
| 700 | + * is reached, the entity logging will be truncated at maxEntitySize and "...more..." will be added at |
| 701 | + * the end of the log entry. If maxEntitySize is <= 0, entity logging will be disabled |
| 702 | + * @param maskedHeaderNames a list of header names that should have the values masked |
| 703 | + */ |
| 704 | + public void enableRequestResponseLogging(Level level, int maxEntitySize, List<String> maskedHeaderNames) { |
| 705 | + apiClient.enableRequestResponseLogging(LOGGER, level, maxEntitySize, maskedHeaderNames); |
| 706 | + } |
| 707 | + |
| 708 | + /** |
| 709 | + * Enable the logging of the requests to and the responses from the GitLab server API using the |
| 710 | + * specified logger. |
| 711 | + * |
| 712 | + * @param logger the Logger instance to log to |
| 713 | + * @param level the logging level (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST) |
| 714 | + * @param maxEntitySize maximum number of entity bytes to be logged. When logging if the maxEntitySize |
| 715 | + * is reached, the entity logging will be truncated at maxEntitySize and "...more..." will be added at |
| 716 | + * the end of the log entry. If maxEntitySize is <= 0, entity logging will be disabled |
| 717 | + * @param maskedHeaderNames a list of header names that should have the values masked |
| 718 | + */ |
| 719 | + public void enableRequestResponseLogging(Logger logger, Level level, int maxEntitySize, List<String> maskedHeaderNames) { |
| 720 | + apiClient.enableRequestResponseLogging(logger, level, maxEntitySize, maskedHeaderNames); |
637 | 721 | }
|
638 | 722 |
|
639 | 723 | /**
|
|
0 commit comments