コード例 #1
0
ファイル: Logging.cs プロジェクト: fagan2888/Schematic
        internal static void LogCommandRetry(IDbConnectionFactory connectionFactory, Guid commandId, string sql, object?param, int retryAttempt, TimeSpan delay)
        {
            if (connectionFactory == null)
            {
                throw new ArgumentNullException(nameof(connectionFactory));
            }
            if (sql.IsNullOrWhiteSpace())
            {
                throw new ArgumentNullException(nameof(sql));
            }
            if (!ConnectionLoggerLookup.TryGetValue(connectionFactory, out var loggingConfig))
            {
                return;
            }
            if (!ConnectionRegistry.TryGetConnectionId(connectionFactory, out var connectionId))
            {
                connectionId = Guid.Empty;
            }

            var parameters = ToDictionary(param);

            loggingConfig.Logger.Log(
                loggingConfig.LogLevel,
                "Connection {connectionId} is retrying {commandId}, attempt #{retryAttempt} after a delay of {delay}. Attempting to execute {sql} with parameters {@parameters}.",
                connectionId,
                commandId,
                retryAttempt,
                delay,
                sql,
                parameters
                );
        }
コード例 #2
0
ファイル: Logging.cs プロジェクト: fagan2888/Schematic
        internal static void LogCommandExecuted(IDbConnectionFactory connectionFactory, Guid commandId, string sql, object?param, TimeSpan duration)
        {
            if (connectionFactory == null)
            {
                throw new ArgumentNullException(nameof(connectionFactory));
            }
            if (sql.IsNullOrWhiteSpace())
            {
                throw new ArgumentNullException(nameof(sql));
            }
            if (!ConnectionLoggerLookup.TryGetValue(connectionFactory, out var loggingConfig))
            {
                return;
            }
            if (!ConnectionRegistry.TryGetConnectionId(connectionFactory, out var connectionId))
            {
                connectionId = Guid.Empty;
            }

            var parameters = ToDictionary(param);

            loggingConfig.Logger.Log(
                loggingConfig.LogLevel,
                "Connection {connectionId} completed executing query {commandId}. Query {sql} with parameters {@parameters} took {duration}ms to execute.",
                connectionId,
                commandId,
                sql,
                parameters,
                (ulong)duration.TotalMilliseconds
                );
        }