• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

future-architect / uroborosql / #768

10 Sep 2024 05:58PM UTC coverage: 90.35% (-0.9%) from 91.21%
#768

Pull #332

HidekiSugimoto189
Changed to use slf4j v2.0 API
Also added suppressLogging API
Pull Request #332: Enable per-SQL-ID log suppression (#322)

382 of 585 new or added lines in 32 files covered. (65.3%)

9 existing lines in 7 files now uncovered.

8885 of 9834 relevant lines covered (90.35%)

0.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.0
/src/main/java/jp/co/future/uroborosql/log/LoggerBase.java
1
/**
2
 * Copyright (c) 2017-present, Future Corporation
3
 *
4
 * This source code is licensed under the MIT license found in the
5
 * LICENSE file in the root directory of this source tree.
6
 */
7
package jp.co.future.uroborosql.log;
8

9
import org.slf4j.Logger;
10
import org.slf4j.MDC;
11
import org.slf4j.spi.LoggingEventBuilder;
12
import org.slf4j.spi.NOPLoggingEventBuilder;
13

14
/**
15
 * ログ出力する際の共通親インタフェース
16
 */
17
public interface LoggerBase {
18
        /** すべてのログ出力を抑止するためのMDCキー */
19
        String SUPPRESS_LOG_OUTPUT = "UroboroSQL_SuppressLogOutput";
20

21
        /** パラメータログ出力を抑止するためのMDCキー */
22
        String SUPPRESS_PARAMETER_LOG_OUTPUT = "UroboroSQL_SuppressParameterLogOutput";
23

24
        /**
25
         * Uroborosqlが出力するログを抑止する.
26
         */
27
        default void suppressLogging() {
28
                MDC.put(SUPPRESS_LOG_OUTPUT, SUPPRESS_LOG_OUTPUT);
1✔
29
        }
1✔
30

31
        /**
32
         * Uroborosqlが出力するログが抑止されているかを返す.
33
         * @return ログが抑止されている場合<code>true</code>
34
         */
35
        default boolean isSuppressLogging() {
36
                return MDC.get(SUPPRESS_LOG_OUTPUT) != null;
1✔
37
        }
38

39
        /**
40
         * Uroborosqlが出力するログが抑止されている場合、抑止を終了する.
41
         */
42
        default void releaseLogging() {
43
                MDC.remove(SUPPRESS_LOG_OUTPUT);
1✔
44
        }
1✔
45

46
        /**
47
         * Uroborosqlが出力するパラメータログを抑止する.
48
         */
49
        default void suppressParameterLogging() {
50
                MDC.put(SUPPRESS_PARAMETER_LOG_OUTPUT, SUPPRESS_PARAMETER_LOG_OUTPUT);
1✔
51
        }
1✔
52

53
        /**
54
         * Uroborosqlが出力するパラメータログが抑止されているかを返す.
55
         * @return パラメータログが抑止されている場合<code>true</code>
56
         */
57
        default boolean isSuppressParameterLogging() {
58
                return MDC.get(SUPPRESS_PARAMETER_LOG_OUTPUT) != null;
1✔
59
        }
60

61
        /**
62
         * Uroborosqlが出力するパラメータログが抑止されている場合、抑止を終了する.
63
         */
64
        default void releaseParameterLogging() {
65
                MDC.remove(SUPPRESS_PARAMETER_LOG_OUTPUT);
1✔
66
        }
1✔
67

68
        default LoggingEventBuilder atError(final Logger logger) {
69
                if (!isSuppressLogging()) {
1✔
70
                        return logger.atError();
1✔
71
                } else {
NEW
72
                        return NOPLoggingEventBuilder.singleton();
×
73
                }
74
        }
75

76
        default LoggingEventBuilder atWarn(final Logger logger) {
77
                if (!isSuppressLogging()) {
1✔
78
                        return logger.atWarn();
1✔
79
                } else {
NEW
80
                        return NOPLoggingEventBuilder.singleton();
×
81
                }
82
        }
83

84
        default LoggingEventBuilder atInfo(final Logger logger) {
85
                if (!isSuppressLogging()) {
1✔
86
                        return logger.atInfo();
1✔
87
                } else {
88
                        return NOPLoggingEventBuilder.singleton();
1✔
89
                }
90
        }
91

92
        default LoggingEventBuilder atDebug(final Logger logger) {
93
                if (!isSuppressLogging()) {
1✔
94
                        return logger.atDebug();
1✔
95
                } else {
96
                        return NOPLoggingEventBuilder.singleton();
1✔
97
                }
98
        }
99

100
        default LoggingEventBuilder atTrace(final Logger logger) {
101
                if (!isSuppressLogging()) {
1✔
102
                        return logger.atTrace();
1✔
103
                } else {
NEW
104
                        return NOPLoggingEventBuilder.singleton();
×
105
                }
106
        }
107
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc