Repository navigation
Logging
CWIST has three logging facilities:
| Facility | Header | Output | Use |
|---|---|---|---|
| Access log middleware | <cwist/sys/app/middleware.h> |
stdout, one line per request | request logs (common, combined, JSON) |
| Application logger | <cwist/sys/app/logger.h> |
stderr | your own named loggers with levels and colors |
| Internal log macros | <cwist/core/log.h> |
stderr | framework diagnostics |
cwist_app_use(app, cwist_mw_access_log(CWIST_LOG_JSON));{"time":"2026-10-07T10:52:34.123Z","client":"127.0.0.1","rid":"jx6ilguz4yrgd101","method":"GET","path":"/x","protocol":"HTTP/1.1","status":200,"duration_ms":0,"req_bytes":0,"res_bytes":2}
CWIST_LOG_COMMON and CWIST_LOG_COMBINED print Apache-style lines;
combined adds Referer and User-Agent. The request id comes from
cwist_mw_request_id() when it runs earlier in the chain. Requests that match
no route are not logged (middleware does not run on route misses; see
Middleware).
#include <cwist/sys/app/logger.h>
cwist_logger *log = cwist_logger_create("billing");
cwist_logger_set_level(log, CWIST_LOG_INFO);
cwist_logger_set_colors(log, true);
cwist_logger_info(log, "charged %d cents", 1299);
cwist_logger_destroy(log);| Function | Description |
|---|---|
cwist_logger *cwist_logger_create(const char *name) / void cwist_logger_destroy(cwist_logger *log)
|
Named logger. |
void cwist_logger_set_level(log, level) |
Minimum level: CWIST_LOG_DEBUG, _INFO, _WARN, _ERROR. |
void cwist_logger_set_colors(log, bool) |
ANSI colors. |
cwist_logger_log(log, level, fmt, ...), _debug, _info, _warn, _error
|
printf-style output. |
CWIST_LOG_INFO(fmt, ...), CWIST_LOG_WARN, CWIST_LOG_ERROR and
CWIST_LOG_DEBUG write [LEVEL] [YYYY-MM-DD HH:MM:SS] message to stderr when
the global g_cwist_log_level allows it. The default is
CWIST_LOG_LEVEL_NONE, so the framework's internal logs are silent until you
set the variable:
#include <cwist/core/log.h>
g_cwist_log_level = CWIST_LOG_LEVEL_INFO; /* INFO, WARN and ERROR */The level test happens before the arguments are evaluated, so disabled log
calls cost almost nothing. cwist_log_init() is declared in the header but
not implemented; set g_cwist_log_level directly.
Separate environment switches enable specific diagnostics:
CWIST_ASYNC_DEBUG (reactor and async-path failures) and CWIST_H3_DEBUG
(lsquic logs); see Configuration and Environment.
CWIST wiki, written against the dev branch of c4punks/CWIST. Pages marked "Source:" are generated from files under docs/; fix those in the repository. Questions: Discord.
Getting started
- Installation
- Quick Start
- Linking
- Server Modes
- Configuration and Environment
- Project CLI
- Tutorial / Korean
- Examples and Tutorials
Guides
Core
- API Reference
- Application
- Routing
- Middleware
- Requests and Responses
- Async Handlers
- Streaming Responses
- Error Handling
- Graceful Shutdown
- Multiport
Protocols
- HTTPS and TLS
- HTTP/2
- HTTP/3 and QUIC
- WebTransport
- WebSocket
- Server-Sent Events
- gRPC Server
- gRPC Client
- Protobuf and Codegen
- GraphQL
- WebRTC DataChannels
- HTTP Clients
Web features
- Static Files and Assets
- Big Dumb Reply Cache
- Compression
- Cookies
- Sessions and Flash
- Query Maps
- Multipart Uploads
- HTML Components
- Templates
- JSON
- Validation
- OpenAPI
Security
Data
Runtime
- Memory Management
- Full GC
- Async GC Ownership
- SString
- Reactor and I/O
- Metrics and Health
- Logging
- Testing
Platforms
Performance notes
- Benchmark Methodology
- C1M File Limits
- Reactor Fairness
- Cooperative Queuing
- Classic Pool Starvation
- Reactor Wakeup
- wrk Dual Histogram
- FIXED Endpoint Cache
- ADR-0001
- Durable Queue Gate
- Mux References
Project