public TelegramLogger( string category, ITelegramBotClient botClient, TelegramLoggerOptions options, Func <string, LogLevel, bool> filter) : this(category, new TelegramLoggerSender(botClient, options.ChatId), options, filter) { }
public static ILoggerFactory AddTelegramLogger( this ILoggerFactory loggerFactory, TelegramLoggerOptions options, Func <string, LogLevel, bool> filter = default) { var botClient = new TelegramBotClient(options.BotToken); loggerFactory?.AddProvider(new TelegramLoggerProvider(botClient, options, filter)); return(loggerFactory); }
public static ILoggerFactory AddTelegramLogger( this ILoggerFactory loggerFactory, Action <TelegramLoggerOptions> configure, Func <string, LogLevel, bool> filter = default) { var options = new TelegramLoggerOptions(); configure(options); return(loggerFactory?.AddTelegramLogger(options, filter)); }
internal TelegramLogger( string category, TelegramLoggerSender messageQueue, TelegramLoggerOptions options, Func <string, LogLevel, bool> filter) { _category = category ?? throw new ArgumentNullException(nameof(category)); _messageQueue = messageQueue; _filter = filter ?? ((cat, logLevel) => true); _options = options; }
public TelegramLoggerProvider( ITelegramBotClient botClient, TelegramLoggerOptions options, Func <string, LogLevel, bool> filter) { if (string.IsNullOrEmpty(options.ChatId) || string.IsNullOrWhiteSpace(options.ChatId)) { throw new ArgumentException("Log receiver Id should not be null, empty or be a whitespace"); } if (string.IsNullOrEmpty(options.SourceName) || string.IsNullOrWhiteSpace(options.SourceName)) { throw new ArgumentException("Source name should not be null, empty or be a whitespace"); } _filter = filter; _options = options; _messageQueue = new TelegramLoggerSender(botClient, options.ChatId); }