/// <summary>
        /// Adds the WriteTo.InfluxDB() extension method to <see cref="LoggerConfiguration"/>.
        /// </summary>
        public static LoggerConfiguration InfluxDB(
            this LoggerSinkConfiguration loggerConfiguration,
            string source,
            string address,
            string dbName,
            string username,
            string password,
            string retentionPolicy = InfluxDBDefaults.DefaultRetentionPolicy,
            LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
            int batchPostingLimit          = InfluxDBSink.DefaultBatchPostingLimit,
            TimeSpan?period                = null,
            IFormatProvider formatProvider = null)
        {
            var connectionInfo = new InfluxDBConnectionInfo
            {
                Address         = address,
                Port            = InfluxDBDefaults.DefaultPort,
                DbName          = dbName,
                RetentionPolicy = retentionPolicy,
                Username        = username,
                Password        = password
            };

            return(InfluxDB(loggerConfiguration, source, connectionInfo, restrictedToMinimumLevel, batchPostingLimit, period, formatProvider));
        }
        /// <summary>
        /// Adds the WriteTo.InfluxDB() extension method to <see cref="LoggerConfiguration"/>.
        /// </summary>
        public static LoggerConfiguration InfluxDB(
            this LoggerSinkConfiguration loggerConfiguration,
            string source,
            InfluxDBConnectionInfo connectionInfo,
            LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
            int batchPostingLimit          = InfluxDBSink.DefaultBatchPostingLimit,
            TimeSpan?period                = null,
            IFormatProvider formatProvider = null)
        {
            if (connectionInfo == null)
            {
                throw new ArgumentNullException(nameof(connectionInfo));
            }

            var defaultedPeriod = period ?? InfluxDBSink.DefaultPeriod;

            return(loggerConfiguration.Sink(new InfluxDBSink(connectionInfo, source, batchPostingLimit, defaultedPeriod, formatProvider), restrictedToMinimumLevel));
        }
        public static LoggerConfiguration InfluxDB(
            this LoggerSinkConfiguration loggerConfiguration,
            string source,
            string address,
            int port,
            string dbName,
            string username,
            string password,
            LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
            int batchPostingLimit          = InfluxDBSink.DefaultBatchPostingLimit,
            TimeSpan?period                = null,
            IFormatProvider formatProvider = null)
        {
            if (loggerConfiguration == null)
            {
                throw new ArgumentNullException(nameof(loggerConfiguration));
            }
            if (string.IsNullOrEmpty(address))
            {
                throw new ArgumentNullException(nameof(address));
            }
            if (port <= 0)
            {
                throw new ArgumentException("port");
            }
            if (string.IsNullOrEmpty(dbName))
            {
                throw new ArgumentException("dbName");
            }

            var connectionInfo = new InfluxDBConnectionInfo
            {
                Address  = address,
                Port     = port,
                DbName   = dbName,
                Username = username,
                Password = password
            };

            return(InfluxDB(loggerConfiguration, source, connectionInfo, restrictedToMinimumLevel, batchPostingLimit, period, formatProvider));
        }
        /// <summary>
        /// Adds the WriteTo.InfluxDB() extension method to <see cref="LoggerConfiguration"/>.
        /// </summary>
        public static LoggerConfiguration InfluxDB(
            this LoggerSinkConfiguration loggerConfiguration,
            string applicationName,
            string instanceName,
            InfluxDBConnectionInfo connectionInfo,
            LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
            int batchPostingLimit          = InfluxDBSink.DefaultBatchPostingLimit,
            TimeSpan?period                = null,
            IFormatProvider formatProvider = null)
        {
            if (applicationName == null)
            {
                throw new ArgumentNullException(nameof(applicationName));
            }
            if (connectionInfo == null)
            {
                throw new ArgumentNullException(nameof(connectionInfo));
            }
            if (connectionInfo.Uri == null)
            {
                throw new ArgumentNullException(nameof(connectionInfo.Uri));
            }
            if (connectionInfo.DbName == null)
            {
                throw new ArgumentNullException(nameof(connectionInfo.DbName));
            }
            if (connectionInfo.Username == null)
            {
                connectionInfo.Username = string.Empty;
            }
            if (connectionInfo.Password == null)
            {
                connectionInfo.Password = string.Empty;
            }

            var defaultedPeriod = period ?? InfluxDBSink.DefaultPeriod;

            return(loggerConfiguration.Sink(new InfluxDBSink(connectionInfo, applicationName, instanceName, batchPostingLimit, defaultedPeriod, formatProvider),
                                            restrictedToMinimumLevel));
        }
        /// <summary>
        /// Adds the WriteTo.InfluxDB() extension method to <see cref="LoggerConfiguration"/>.
        /// </summary>
        public static LoggerConfiguration InfluxDB(
            this LoggerSinkConfiguration loggerConfiguration,
            string applicationName,
            string instanceName,
            Uri uri,
            string dbName,
            string username = null,
            string password = null,
            LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
            int batchPostingLimit          = InfluxDBSink.DefaultBatchPostingLimit,
            TimeSpan?period                = null,
            IFormatProvider formatProvider = null)
        {
            if (uri == null)
            {
                throw new ArgumentNullException(nameof(uri));
            }
            if (loggerConfiguration == null)
            {
                throw new ArgumentNullException(nameof(loggerConfiguration));
            }
            if (string.IsNullOrEmpty(dbName))
            {
                throw new ArgumentException("dbName");
            }

            var connectionInfo = new InfluxDBConnectionInfo
            {
                Uri      = uri,
                DbName   = dbName,
                Username = username,
                Password = password
            };

            return(InfluxDB(loggerConfiguration, applicationName, instanceName, connectionInfo,
                            restrictedToMinimumLevel, batchPostingLimit, period, formatProvider));
        }