s-fleck / lgrExtra

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

AppenderDbi with pool object #8

Open EydlinIlya opened 1 year ago

EydlinIlya commented 1 year ago

AppenderDbi works great for shiny apps. The same is applicable for the connection pool produced by {pool} However, pool object can't be used as a connection for the appender

con <- pool::dbPool(RPostgres::Postgres(), 
                    dbname = dbname,
                    host = host, 
                    port = port,
                    user = user, 
                    password = password)
lg <- get_logger("db_logger")
lg$
  set_propagate(FALSE)$
  add_appender(
    name = "db",
    lgrExtra::AppenderDbi$new(
      conn = con,
      table = "audit_log",
      buffer_size = 5L
    )
  )
  #Error in switch(cls, PostgreSQLConnection = LayoutPostgres$new(...), PqConnection = LayoutPostgres$new(...),  : 
  #EXPR must be a length 1 vector

It would be nice to have this functionality

s-fleck commented 1 year ago

thanks for your suggestion. it would be great to support pool objects. sadly i have less time right now to work on this package than i would want to have to so it might take a while till i get around to it :(