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

future-architect / uroborosql / #692

pending completion
#692

push

HidekiSugimoto189
Added output judgment for log output arguments that are string processed

53 of 53 new or added lines in 6 files covered. (100.0%)

7895 of 8761 relevant lines covered (90.12%)

0.9 hits per line

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

80.0
/src/main/java/jp/co/future/uroborosql/filter/DebugSqlFilter.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.filter;
8

9
import java.sql.PreparedStatement;
10
import java.sql.ResultSet;
11
import java.sql.SQLException;
12

13
import org.slf4j.Logger;
14
import org.slf4j.LoggerFactory;
15

16
import jp.co.future.uroborosql.context.SqlContext;
17
import jp.co.future.uroborosql.parameter.Parameter;
18

19
/**
20
 * デバッグログを出力するSqlFilter
21
 *
22
 * @author H.Sugimoto
23
 */
24
public class DebugSqlFilter extends AbstractSqlFilter {
1✔
25
        /** ロガー */
26
        private static final Logger LOG = LoggerFactory.getLogger(DebugSqlFilter.class);
1✔
27

28
        @Override
29
        public Parameter doParameter(final Parameter parameter) {
30
                if (LOG.isDebugEnabled()) {
1✔
31
                        LOG.debug("Parameter:{}", parameter);
1✔
32
                }
33
                return parameter;
1✔
34
        }
35

36
        /**
37
         * {@inheritDoc}
38
         *
39
         * @see jp.co.future.uroborosql.filter.AbstractSqlFilter#doOutParameter(java.lang.String, java.lang.Object)
40
         */
41
        @Override
42
        public Object doOutParameter(final String key, final Object val) {
43
                if (LOG.isDebugEnabled()) {
×
44
                        LOG.debug("Out parameter - Key:{}, value:{}", key, val);
×
45
                }
46
                return val;
×
47
        }
48

49
        /**
50
         * {@inheritDoc}
51
         *
52
         * @see jp.co.future.uroborosql.filter.AbstractSqlFilter#doQuery(jp.co.future.uroborosql.context.SqlContext, java.sql.PreparedStatement, java.sql.ResultSet)
53
         */
54
        @Override
55
        public ResultSet doQuery(final SqlContext sqlContext, final PreparedStatement preparedStatement,
56
                        final ResultSet resultSet) {
57
                if (LOG.isDebugEnabled()) {
1✔
58
                        LOG.debug("SQL:{} executed.", sqlContext.getSqlName());
1✔
59
                }
60
                return resultSet;
1✔
61
        }
62

63
        /**
64
         * {@inheritDoc}
65
         *
66
         * @see jp.co.future.uroborosql.filter.AbstractSqlFilter#doUpdate(jp.co.future.uroborosql.context.SqlContext, java.sql.PreparedStatement, int)
67
         */
68
        @Override
69
        public int doUpdate(final SqlContext sqlContext, final PreparedStatement preparedStatement, final int result) {
70
                if (LOG.isDebugEnabled()) {
1✔
71
                        LOG.debug("SQL:{} executed. Count:{} items.", sqlContext.getSqlName(), result);
1✔
72
                }
73
                return result;
1✔
74
        }
75

76
        /**
77
         * {@inheritDoc}
78
         *
79
         * @see jp.co.future.uroborosql.filter.AbstractSqlFilter#doBatch(jp.co.future.uroborosql.context.SqlContext, java.sql.PreparedStatement, int[])
80
         */
81
        @Override
82
        public int[] doBatch(final SqlContext sqlContext, final PreparedStatement preparedStatement, final int[] result) {
83
                if (LOG.isDebugEnabled()) {
1✔
84
                        int[] counts = result;
1✔
85
                        try {
86
                                counts = new int[] { preparedStatement.getUpdateCount() };
1✔
87
                        } catch (SQLException ex) {
×
88
                                ex.printStackTrace();
×
89
                        }
1✔
90

91
                        StringBuilder builder = new StringBuilder();
1✔
92
                        for (int val : counts) {
1✔
93
                                builder.append(val).append(", ");
1✔
94
                        }
95
                        LOG.debug("SQL:{} executed. Result:{}", sqlContext.getSqlName(), builder.toString());
1✔
96
                }
97
                return result;
1✔
98
        }
99
}
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