Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Implement Logging Infrastructure #52

Merged
merged 4 commits into from
Apr 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ let package = Package(
.package(url: "https://github.com/SwiftDocOrg/Markup.git", .upToNextMinor(from: "0.0.3")),
.package(url: "https://github.com/NSHipster/SwiftSyntaxHighlighter.git", .revision("1.0.0")),
.package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMinor(from: "0.0.2")),
.package(url: "https://github.com/apple/swift-log.git", .upToNextMinor(from: "1.2.0")),
.package(url: "https://github.com/NSHipster/swift-log-github-actions.git", .upToNextMinor(from: "0.0.1")),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "swift-doc",
dependencies: ["ArgumentParser", "SwiftDoc", "SwiftSemantics", "SwiftMarkup", "CommonMarkBuilder", "HypertextLiteral", "Markup", "DCOV", "GraphViz", "SwiftSyntaxHighlighter"]
dependencies: ["ArgumentParser", "SwiftDoc", "SwiftSemantics", "SwiftMarkup", "CommonMarkBuilder", "HypertextLiteral", "Markup", "DCOV", "GraphViz", "SwiftSyntaxHighlighter", "Logging", "LoggingGitHubActions"]
),
.target(
name: "DCOV",
Expand Down
2 changes: 2 additions & 0 deletions Sources/swift-doc/Subcommands/Generate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ extension SwiftDoc {
let url = outputDirectoryURL.appendingPathComponent(filename)
try $0.value.write(to: url, format: format)
}
} catch {
logger.error("\(error)")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ struct Relationships: Component {
do {
svg = try HypertextLiteral.HTML(String(data: graph.render(using: algorithm, to: .svg), encoding: .utf8) ?? "")
} catch {
print(error)
logger.error("\(error)")
}

return #"""
Expand Down
15 changes: 13 additions & 2 deletions Sources/swift-doc/main.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import ArgumentParser
import Foundation
import Logging
import LoggingGitHubActions

LoggingSystem.bootstrap { label in
if ProcessInfo.processInfo.environment["GITHUB_ACTIONS"] == "true" {
return GitHubActionsLogHandler.standardOutput(label: label)
} else {
return StreamLogHandler.standardOutput(label: label)
}
}

let logger = Logger(label: "org.swiftdoc.swift-doc")

let fileManager = FileManager.default
let fileAttributes: [FileAttributeKey : Any] = [.posixPermissions: 0o744]
Expand All @@ -10,8 +22,7 @@ var standardError = FileHandle.standardError
struct SwiftDoc: ParsableCommand {
static var configuration = CommandConfiguration(
abstract: "A utility for generating documentation for Swift code.",
subcommands: [Generate.self, Coverage.self, Diagram.self],
defaultSubcommand: Generate.self
subcommands: [Generate.self, Coverage.self, Diagram.self]
)
}

Expand Down