-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoggingController.cs
46 lines (41 loc) · 1.2 KB
/
LoggingController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Collections.Concurrent;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
namespace Poc.LambdaExtension.Logging.Controllers
{
[ApiController]
[Route("[controller]")]
public class LoggingController : ControllerBase
{
private readonly ILogger<LoggingController> _logger;
private readonly ConcurrentQueue<string> _logsQueue;
public LoggingController(
ILogger<LoggingController> logger,
ConcurrentQueue<string> logsQueue)
{
_logger = logger;
_logsQueue = logsQueue;
}
[HttpGet]
public IActionResult Get()
{
_logger.LogInformation("get");
return Ok(new { message = "get" });
}
[HttpPost]
public IActionResult LogsCallback(object payload)
{
try
{
_logsQueue.Enqueue(payload.ToString());
return Ok(new { message = "ok" });
}
catch (Exception ex)
{
_logger.LogError(ex, "Error@LogsCallback");
throw;
}
}
}
}