thomasp85 / fiery

A flexible and lightweight web server
https://fiery.data-imaginist.com
Other
244 stars 12 forks source link

Combined log format doesn't seem to work #24

Closed cpsievert closed 6 years ago

cpsievert commented 6 years ago
library(fiery)

# Create a New App
app <- Fire$new()

# Handle requests
app$on('request', function(server, request, ...) {
  response <- request$respond()
  response$status <- 200L
  response$body <- paste0('<h1>This is indeed a test. You are number ', server$get_data('visits'), '</h1>')
  response$type <- 'html'
})

# works as expected
app$set_logger(logger_console())

# doesn't work
# app$set_logger(logger_console(combined_log_format))

app$ignite(showcase = TRUE)

More generally, it seems like errors/warnings from the logger itself should be reported in some way to help debug these sort of issues

thomasp85 commented 6 years ago

Access log formats are set by the access_log_format field

see ?loggers for more info

thomasp85 commented 6 years ago

WRT errors from the logger itself I have not been able to come up with a sensible approach without running the risk of creating an infinity recursion...

cpsievert commented 6 years ago

Ahh, ok. I still don't see any output for this example?

library(fiery)

app <- Fire$new()
app$on('request', function(server, request, ...) {
  response <- request$respond()
  response$status <- 200L
  response$body <- paste0('<h1>This is indeed a test. You are number ', server$get_data('visits'), '</h1>')
  response$type <- 'html'
})

app$access_log_format <- combined_log_format
app$ignite(showcase = TRUE)
thomasp85 commented 6 years ago

Oh, you are correct - there are some problems with glue that should be fixed