Skip to content

Commit

Permalink
Add log level to HBApplication.Configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler committed Mar 30, 2021
1 parent 1d32bb4 commit 66af6d7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 5 additions & 2 deletions Sources/Hummingbird/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public final class HBApplication: HBExtensible {
/// Application extensions
public var extensions: HBExtensions<HBApplication>
/// Logger
public var logger: Logger
public let logger: Logger
/// Encoder used by router
public var encoder: HBResponseEncoder
/// decoder used by router
Expand All @@ -55,14 +55,17 @@ public final class HBApplication: HBExtensible {
eventLoopGroupProvider: NIOEventLoopGroupProvider = .createNew
) {
self.lifecycle = ServiceLifecycle()
self.logger = Logger(label: "HummingBird")
self.middleware = HBMiddlewareGroup()
self.router = TrieRouter()
self.configuration = configuration
self.extensions = HBExtensions()
self.encoder = NullEncoder()
self.decoder = NullDecoder()

var logger = Logger(label: "HummingBird")
logger.logLevel = configuration.logLevel
self.logger = logger

// create eventLoopGroup
self.eventLoopGroupProvider = eventLoopGroupProvider
switch eventLoopGroupProvider {
Expand Down
7 changes: 6 additions & 1 deletion Sources/Hummingbird/Configuration.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import HummingbirdCore
import Logging

extension HBApplication {
// MARK: Configuration
Expand Down Expand Up @@ -26,6 +27,8 @@ extension HBApplication {

/// Number of threads to allocate in the application thread pool
public let threadPoolSize: Int
/// logging level
public let logLevel: Logger.Level

// MARK: Initialization

Expand All @@ -39,7 +42,8 @@ extension HBApplication {
reuseAddress: Bool = true,
tcpNoDelay: Bool = false,
enableHttpPipelining: Bool = true,
threadPoolSize: Int = 2
threadPoolSize: Int = 2,
logLevel: Logger.Level = .info
) {
self.address = address
self.serverName = serverName
Expand All @@ -51,6 +55,7 @@ extension HBApplication {
self.enableHttpPipelining = enableHttpPipelining

self.threadPoolSize = threadPoolSize
self.logLevel = logLevel
}

/// return HTTP server configuration
Expand Down

0 comments on commit 66af6d7

Please sign in to comment.