drogonframework / drogonframework/drogon

ERROR Plugin drogon::plugin::AccessLogger undefined!

Open
#1,561 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
14.3k
Forks
1.4k
Avg merge
1d 13h
Merged PRs (30d)
14

Description

**Describe the bug**
Plugin `AccessLogger` is undefined unless `drogon/plugins/AccessLogger.h` is included. Some examples use `drogon/drogon.h` which includes all drogon files, but some others use specific `drogon/HttpAppFramework.h` or `drogon/HttpController.h`. This is either bug in the library or in the documentation because wiki [page](https://github.com/drogonframework/drogon/wiki/ENG-09-Plugins) for plugins doesn't mention that you need to include file for it.

**To Reproduce**

main.cpp:

```c++
#include
#include
#include

//#include // it works if I uncomment this

struct Controller : drogon::HttpController {
METHOD_LIST_BEGIN
ADD_METHOD_TO(Controller::hello, "/", drogon::Get);
METHOD_LIST_END

void
hello(const drogon::HttpRequestPtr &req,
std::function &&callback) const {
auto resp = drogon::HttpResponse::newHttpResponse();
resp->setBody("

Hello, world!

");
callback(resp);
}
};

int main() {
drogon::app().loadConfigFile("drogon_config.json").run();
}
```

meson.build:

```meson
project(
'drogon-mre',
['cpp'],
default_options: ['cpp_std=c++17'],
meson_version: '>=0.60'
)
drogon_dep = dependency('drogon', include_type: 'system')
executable('a', ['main.cpp'], dependencies: [drogon_dep])
```

conanfile.py:

```python
from conan import ConanFile
from conan.tools.gnu import PkgConfigDeps
from conan.tools.meson import MesonToolchain, Meson

class App(ConanFile):
settings = "os", "arch", "compiler", "build_type"

def requirements(self):
self.requires("drogon/1.8.3")
self.requires("openssl/1.1.1t", force=True)

def generate(self):
tc = MesonToolchain(self)
tc.generate()
pc = PkgConfigDeps(self)
pc.generate()

def build(self):
meson = Meson(self)
meson.configure()
meson.build()
```

drogon_config.json:

```json
{
"listeners": [
{
"address": "::1",
"port": 8080
}
],
"app": {
"log": {
"log_level": "WARN"
}
},
"plugins": [
{
"name": "drogon::plugin::AccessLogger",
"config": {
"log_format": "$request_date $remote_addr $method $url $status $body_bytes_sent $processing_time"
}
}
]
}
```

Build:

```bash
$ mkdir build && cd build
$ conan build .. --output-folder . -s build_type=Debug --build=missing
$ ./a
20230410 10:36:54.390061 UTC 146065 ERROR Plugin drogon::plugin::AccessLogger undefined! - PluginsManager.cc:97
```

**Desktop:**
- OS: Arch Linux, Ubuntu 22.04
- drogon 1.8.3
- gcc 12.2.1 20230201
- Conan 2.0.3

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.