Skip to content

Commit

Permalink
More logs
Browse files Browse the repository at this point in the history
  • Loading branch information
shemanaev committed Jan 28, 2024
1 parent 163cedb commit fb4385d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion Jellyfin.Webhooks/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,15 +356,21 @@ private async Task ExecuteWebhook(EventInfo request)
{
var hooks = Plugin.Instance.Configuration.Hooks
.Where(h => h.Events.Contains(request.Event));

_logger.LogInformation("ExecuteWebhook: hooks {hooks}, event: {evt}", hooks.Count(), request.Event);

foreach (var hook in hooks)
{
if (!string.IsNullOrEmpty(hook.UserId) && request.User?.Id.ToString("N") != hook.UserId)
{
_logger.LogWarning("ExecuteWebhook: user mismatch, hook.UserId: {hookUserId}, request.User: {reqUser}, event: {evt}", hook.UserId, request.User, request.Event);
continue;
}

var formatter = _formatFactory.CreateFormat(hook.Format);
try
{
_logger.LogInformation("ExecuteWebhook: {id}, format: {format}, url: {url}", hook.Id, hook.Format, hook.Url);
_logger.LogInformation("ExecuteWebhook: {id}, format: {format}, url: {url}, event: {evt}", hook.Id, hook.Format, hook.Url, request.Event);
await formatter.Format(new Uri(hook.Url), request);
}
catch (Exception e)
Expand Down
4 changes: 2 additions & 2 deletions Jellyfin.Webhooks/Formats/DefaultFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public async Task Format(Uri url, EventInfo info)

var contentJson = JsonSerializer.Serialize(body, JsonDefaults.Options);
var content = new StringContent(contentJson, Encoding.UTF8, "application/json");
_logger.LogInformation("Calling url: {url} (size: {size})", url, contentJson.Length);
_logger.LogInformation("Calling url: {url} (size: {size}), event: {evt}", url, contentJson.Length, info.Event);
var response = await _http.PostAsync(url, content);
_logger.LogInformation($"Response: {response}");
_logger.LogInformation("event: {evt}, Response: {response}", info.Event, response);
}
}

Expand Down

0 comments on commit fb4385d

Please sign in to comment.