Structure
PolicyLogHandler
public struct PolicyLogHandler: LogHandler
This struct implements a custom logging backend (aka LogHandler
)
for the Swift-log library.
This is an example showing how to use this logging backend:
import Logging
import kubewardenSdk
// This can be done once, like inside of the `main.swift` file
// where all the waPC callbacks are registered
LoggingSystem.bootstrap(PolicyLogHandler.init)
let logger = Logger(label: "my-policy")
logger.info("Hello World!")
let name = "world"
logger.info("hello \(name)")
logger.info("Another message",
metadata: [
"foo": "bar",
"number": .stringConvertible(42),
"more-numbers": [.stringConvertible(1), .stringConvertible(2)],
])
Relationships
Conforms To
LogHandler
Initializers
init(label:)
public init(label: String)
Properties
label
public let label: String
logLevel
public var logLevel: Logger.Level = .info
metadata
public var metadata
Methods
log(level:message:metadata:file:function:line:)
public func log(level: Logger.Level,
message: Logger.Message,
metadata: Logger.Metadata?,
file: String, function: String, line: UInt)