leodido / caddy-conditional-logging Goto Github PK
View Code? Open in Web Editor NEWCaddy log encoder for conditional logging
License: Apache License 2.0
Caddy log encoder for conditional logging
License: Apache License 2.0
When trying to build the extension I get this:
#13 146.9 2023/01/23 07:57:24 [INFO] exec (timeout=0s): /usr/local/go/bin/go build -o /usr/bin/caddy -ldflags -w -s -trimpath
#13 160.8 # github.com/leodido/caddy-conditional-logging
#13 160.8 /go/pkg/mod/github.com/leodido/[email protected]/plugin.go:153:14: cannot use ctx.Logger (value of type func(module ...caddy.Module) *zap.Logger) as type func(caddy.Module) *zap.Logger in assignment
#13 163.1 2023/01/23 07:57:41 [INFO] Skipping cleanup as requested; leaving folder intact: /tmp/buildenv_2023-01-23-0754.2686892640
The Dockerfile I use:
FROM caddy:2.6.2-builder AS builder
RUN xcaddy build \
--with github.com/leodido/caddy-conditional-logging
I was trying to use the caddy add-package
command to add this plugin to my caddy-server and the command failed with:
Error: download failed: download failed: HTTP 400: github.com/leodido/caddy-conditional-logging is not a registered Caddy module package path (id=5d1b150e-cac2-4ce6-a5af-6ba42eaf1da3
This module also does not show up on Caddy's download page: https://caddyserver.com/download
When the user does not specify the Caddy encoder (eg., json or console) to use, this plugin automatically creates one depending on the environment (console if it's run in a terminal, json otherwise).
log {
format if {
ts sw 2021
}
}
Anyways, it seems that in this case the plugin is not working correctly causing the server to terminate the connection.
This does NOT happen in case the user explicitly expresses the encoder:
log {
format if {
ts sw 2021
} console
}
Needs investigation.
It's not working (at the moment) when using Caddy encoders other than the json
one.
The reason is that the conditions' expressions matching logic expects the buffer to contain JSON data.
To solve this a possible solution would be:
I told some users in caddyserver/transform-encoder#18 (comment) that they could use this plugin along with the transform
encoder, but apparently this plugin doesn't allow it because of the switch here:
caddy-conditional-logging/plugin.go
Line 171 in 8534d30
This plugin should allow any encoder module to be a child.
(That said, there's now a skip_log
directive built into Caddy since v2.6 so this plugin probably isn't really needed anymore)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.