s-fleck / lgrExtra

Extra Appenders for the lgr Package
https://s-fleck.github.io/lgrExtra/
Other
7 stars 2 forks source link

Feature Request: AppenderAWSCloudWatchLog #9

Open DyfanJones opened 11 months ago

DyfanJones commented 11 months ago

A similar idea to https://github.com/s-fleck/lgrExtra/issues/2, however using AWS CloudWatch logs. To achieve this I use paws to make the connection with AWS.

I have got an initial version of this on my folk: https://github.com/DyfanJones/lgrExtra/tree/aws_cloudwatch

remotes::install_github("dyfanjones/lgrExtra")
library(lgrExtra)

app <- AppenderAWSCloudWatchLog$new(log_group_name = "lgrExtra")
lg <- lgr::get_logger("lgrExtra")$add_appender(app)$set_propagate(FALSE)
lg$info("Foo")
lg$warn("Bar")
lg$error("cho")

> app$log_group_name
[1] "lgrExtra"
> app$log_stream_name
[1] "lgrExtra/2023-09-22/bm6qnrzt"
> app$data
[[1]]
[1] "INFO : Foo"

[[2]]
[1] "WARN : Bar"

[[3]]
[1] "ERROR: cho"

image

Let me know if your interested in adding this feature. I haven't added any unit tests as of yet, but happy to work on this.

s-fleck commented 11 months ago

Thank you! I'll look at it. Sadly i don't have much time for my private projects in the last year or so but i'll see if i can get it merged ;)

DyfanJones commented 11 months ago

Cool, I will tidy up the code and raise a PR :)