aboutsummaryrefslogtreecommitdiff
path: root/web/apache/log
diff options
context:
space:
mode:
Diffstat (limited to 'web/apache/log')
-rw-r--r--web/apache/log50
1 files changed, 45 insertions, 5 deletions
diff --git a/web/apache/log b/web/apache/log
index 0e39420..151efb4 100644
--- a/web/apache/log
+++ b/web/apache/log
@@ -5,7 +5,11 @@
#ifndef WEB_APACHE_LOG
#define WEB_APACHE_LOG
-#include <cstdint> // uint64_t
+#include <algorithm> // min()
+#include <cstdint> // uint64_t
+
+#include <httpd/httpd.h> // request_rec
+#include <httpd/http_log.h>
#include <web/module>
@@ -16,7 +20,8 @@ namespace web
class log: public web::log
{
public:
- // ...
+
+ log (request_rec* req) noexcept : req_ (req) {}
virtual void
write (const char* msg) {write (APLOG_ERR, msg);}
@@ -24,13 +29,48 @@ namespace web
// Apache-specific interface.
//
void
- write (int level, const char* msg) {write (nullptr, 0, level, msg);}
+ write (int level, const char* msg)
+ {
+ write (nullptr, 0, nullptr, level, msg);
+ }
void
- write (const char* file, std::uint64_t line, int level, const char* msg);
+ write (const char* file,
+ std::uint64_t line,
+ const char* func,
+ int level,
+ const char* msg)
+ {
+ if (file && *file)
+ file = nullptr; // skip file/line placeholder from log line.
+
+ level = std::min (level, APLOG_TRACE8);
+
+ if (func)
+ ap_log_rerror (file,
+ line,
+ APLOG_NO_MODULE,
+ level,
+ 0,
+ req_,
+ "[%s]: %s",
+ func,
+ msg);
+ else
+ // skip function name placeholder from log line
+ //
+ ap_log_rerror (file,
+ line,
+ APLOG_NO_MODULE,
+ level,
+ 0,
+ req_,
+ ": %s",
+ msg);
+ }
private:
- // ...
+ request_rec* req_;
};
}
}