Skip to content

feat: Adopt swift-log#47

Merged
djones6 merged 9 commits intoKitura:masterfrom
djones6:swift-log
Jun 6, 2019
Merged

feat: Adopt swift-log#47
djones6 merged 9 commits intoKitura:masterfrom
djones6:swift-log

Conversation

@djones6
Copy link
Copy Markdown
Contributor

@djones6 djones6 commented Jun 5, 2019

Provides a way for applications written against LoggerAPI (such as Kitura) to log via swift-log, either as an alternative or in addition to a LoggerAPI logger (such as HeliumLogger).

This introduces a new dependency on that project, using their recommended syntax for compatibility with Swift 4 (swift-log 0.x release) and Swift 5 (1.x release).

It also adds locking around accesses to the logger and swiftLogger global variables, as these are accessed by multiple threads. Although these vars may typically be assigned once during application init, there's nothing to prevent them from being reassigned during execution - nor would we want to prevent them from being reassigned: for example, in response to some event, an application might decide it would be helpful to increase log verbosity or start logging to a file.

Resolves #46

///
/// - Returns: A Boolean indicating whether a message of the specified type
/// will be logged via the registered `LoggerAPI.Logger`.
public class func isLoggingToLoggerAPI(_ level: LoggerMessageType) -> Bool {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this public API carries its weight. We can always add it in future if needed but for now I think internal is fine.

///
/// - Returns: A Boolean indicating whether a message of the specified type
/// will be logged via the registered `Logging.Logger`.
public class func isLoggingToSwiftLog(_ level: LoggerMessageType) -> Bool {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this public API carries its weight. We can always add it in future if needed but for now I think internal is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adopt swift-log

3 participants