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

loresoft / FluentCommand / 6648415992

26 Oct 2023 01:49AM UTC coverage: 51.645% (+0.1%) from 51.515%
6648415992

push

github

pwelter34
Update InsertBuilder.cs

981 of 2442 branches covered (0.0%)

Branch coverage included in aggregate %.

2896 of 5065 relevant lines covered (57.18%)

156.37 hits per line

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

77.78
/src/FluentCommand/DataQueryLogger.cs
1
using System.Data;
2

3
using Microsoft.Extensions.Logging;
4

5
namespace FluentCommand;
6

7
/// <summary>
8
/// A class for logging queries 
9
/// </summary>
10
/// <seealso cref="FluentCommand.IDataQueryLogger" />
11
public partial class DataQueryLogger : IDataQueryLogger
12
{
13
    private readonly ILogger<DataQueryLogger> _logger;
14
    private readonly IDataQueryFormatter _formatter;
15

16
    /// <summary>
17
    /// Initializes a new instance of the <see cref="DataQueryLogger"/> class.
18
    /// </summary>
19
    /// <param name="logger">The logger.</param>
20
    /// <param name="formatter">The formatter for the data command</param>
21
    public DataQueryLogger(ILogger<DataQueryLogger> logger, IDataQueryFormatter formatter)
22
    {
23
        _logger = logger;
3✔
24
        _formatter = formatter;
3✔
25
    }
3✔
26

27
    /// <summary>
28
    /// Log the current specified <paramref name="command" />
29
    /// </summary>
30
    /// <param name="command">The command to log.</param>
31
    /// <param name="duration">The execution duration.</param>
32
    /// <param name="exception">The exception thrown when executing the command.</param>
33
    /// <param name="state">The state used to control logging.</param>
34
    /// <exception cref="System.ArgumentNullException">command</exception>
35
    public virtual void LogCommand(IDbCommand command, TimeSpan duration, Exception exception = null, object state = null)
36
    {
37
        if (_logger == null)
140!
38
            return;
×
39

40
        if (command is null)
140!
41
            throw new ArgumentNullException(nameof(command));
×
42

43
        var output = _formatter.FormatCommand(command, duration, exception);
140✔
44

45
        if (exception == null)
140✔
46
            LogCommand(output);
138✔
47
        else
48
            LogError(output, exception);
2✔
49
    }
2✔
50

51
    [LoggerMessage(0, LogLevel.Debug, "{output}")]
52
    private partial void LogCommand(string output);
53

54
    [LoggerMessage(1, LogLevel.Error, "{output}")]
55
    private partial void LogError(string output, Exception exception);
56
}
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