Skip to content

Commit

Permalink
log fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Szer committed Sep 26, 2023
1 parent 70a35a2 commit c34c498
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/VahterBanBot/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ open Giraffe
open Microsoft.Extensions.DependencyInjection
open VahterBanBot.Utils

type Root = class end

[<CLIMutable>]
type BotConfiguration =
{ BotToken: string
Expand Down Expand Up @@ -38,6 +40,8 @@ let builder = WebApplication.CreateBuilder()
let options = TelegramBotClientOptions(botConf.BotToken)
TelegramBotClient(options, httpClient) :> ITelegramBotClient)

%builder.Logging.AddConsole()

match Environment.GetEnvironmentVariable "APPLICATIONINSIGHTS_CONNECTION_STRING" with
| null -> ()
| appInsightKey ->
Expand Down Expand Up @@ -71,7 +75,7 @@ let server = app.RunAsync()
let telegramClient = builder.Services.BuildServiceProvider().GetRequiredService<ITelegramBotClient>()
telegramClient.SendTextMessageAsync(ChatId(botConf.LogsChannelId), "Bot started").Wait()

let topLogger = builder.Services.BuildServiceProvider().GetRequiredService<ILogger>()
let topLogger = builder.Services.BuildServiceProvider().GetService<ILogger<Root>>()
topLogger.LogInformation("Bot started")

server.Wait()

0 comments on commit c34c498

Please sign in to comment.