Skip to content

Commit

Permalink
More debug output.
Browse files Browse the repository at this point in the history
  • Loading branch information
jskripsky committed Nov 21, 2023
1 parent cef8c28 commit 8f7c711
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
36 changes: 19 additions & 17 deletions src/Main.fs
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,28 @@ module Main =
let main (args: string[]): int =
let secrets = getSecretsFromEnvironment ()

let log = Logger.createMultiLogger [
Logger.createConsoleLogger ()
Logger.createStringLogger (Ntfy.post secrets.NtfyTopic)
]

let result =
if isNull secrets.GotCourts.ApiKey || isNull secrets.GotCourts.PhpSessionId then
log.Write (Error, "💥", sprintf "Please set environment variables '%s' and '%s'." apiKeyName phpSessionIdName)
if isNull secrets.GotCourts.ApiKey || isNull secrets.GotCourts.PhpSessionId || isNull secrets.NtfyTopic then
printfn "💥 Please set environment variables '%s', '%s', and '%s'." apiKeyName phpSessionIdName ntfyTopicName
1
else
try
use gotCourtsClient = GotCourts.createClient secrets.GotCourts
let res = Jobs.groundFrostCheck log gotCourtsClient
if Result.isOk res then 0 else 1
let log = Logger.createMultiLogger [
Logger.createConsoleLogger ()
Logger.createStringLogger (Ntfy.post secrets.NtfyTopic)
]

with
| exn ->
log.Write (Error, "💥", sprintf "Exception thrown: %A." exn)
1

log.Close ()
try
try
use gotCourtsClient = GotCourts.createClient secrets.GotCourts
let res = Jobs.groundFrostCheck log gotCourtsClient
if Result.isOk res then 0 else 1

with
| exn ->
log.Write (Error, "💥", sprintf "Exception thrown: %A." exn)
1

finally
log.Close ()

result
8 changes: 7 additions & 1 deletion src/Ntfy.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace TcFairplay

open System.Net
open System.Net.Http

module Ntfy =
Expand All @@ -14,5 +15,10 @@ module Ntfy =
printfn "Posting text to ntfy.sh."
let resp = client.PostAsync(url, sc) |> await

printfn "StatusCode: %A" resp.StatusCode
if resp.StatusCode <> HttpStatusCode.OK then
printfn "Error! Reason: %s" resp.ReasonPhrase
printfn "Length of topic name: %d chars." topic.Length
else
printfn "OK."

()

0 comments on commit 8f7c711

Please sign in to comment.