-
Notifications
You must be signed in to change notification settings - Fork 20
/
logger.go
53 lines (42 loc) · 1.2 KB
/
logger.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright 2022 The OWASP Coraza contributors
// SPDX-License-Identifier: Apache-2.0
package main
import (
"io"
"github.com/corazawaf/coraza/v3"
"github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm"
)
type debugLogger struct {
level coraza.LogLevel
}
func (l *debugLogger) Info(message string, args ...interface{}) {
if l.level >= coraza.LogLevelInfo {
proxywasm.LogInfof(message, args...)
}
}
func (l *debugLogger) Warn(message string, args ...interface{}) {
if l.level >= coraza.LogLevelWarn {
proxywasm.LogWarnf(message, args...)
}
}
func (l *debugLogger) Error(message string, args ...interface{}) {
if l.level >= coraza.LogLevelError {
proxywasm.LogErrorf(message, args...)
}
}
func (l *debugLogger) Debug(message string, args ...interface{}) {
if l.level >= coraza.LogLevelDebug {
proxywasm.LogDebugf(message, args...)
}
}
func (l *debugLogger) Trace(message string, args ...interface{}) {
if l.level >= coraza.LogLevelTrace {
proxywasm.LogTracef(message, args...)
}
}
func (l *debugLogger) SetLevel(level coraza.LogLevel) {
l.level = level
}
func (l *debugLogger) SetOutput(w io.Writer) {
proxywasm.LogWarn("ignoring SecDebugLog directive, debug logs are always routed to proxy logs")
}