Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
4 changes: 2 additions & 2 deletions .github/workflows/api-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ jobs:
secrets: inherit
with:
package_name: console-kit
modules: ConsoleKit
pathsToInvalidate: /consolekit/*
modules: ConsoleKit,ConsoleLogger
pathsToInvalidate: /consolekit/* /consolelogger/*
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
unit-tests:
uses: vapor/ci/.github/workflows/run-unit-tests.yml@main
with:
# with_windows: true
with_windows: true
with_musl: true
with_android: true
with_linting: true
Expand Down
31 changes: 27 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ let package = Package(
.tvOS(.v18),
],
products: [
.library(name: "ConsoleKit", targets: ["ConsoleKit"])
.library(name: "ConsoleKit", targets: ["ConsoleKit"]),
.library(name: "ConsoleLogger", targets: ["ConsoleLogger"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-log.git", from: "1.6.3"),
Expand All @@ -20,20 +21,37 @@ let package = Package(
.target(
name: "ConsoleKit",
dependencies: [
.product(name: "Logging", package: "swift-log"),
.product(name: "AsyncAlgorithms", package: "swift-async-algorithms"),
.product(name: "AsyncAlgorithms", package: "swift-async-algorithms")
Comment thread
gwynne marked this conversation as resolved.
],
swiftSettings: swiftSettings
),
.testTarget(
name: "ConsoleKitTests",
dependencies: [.target(name: "ConsoleKit")],
dependencies: [
.target(name: "ConsoleKit")
Comment thread
gwynne marked this conversation as resolved.
],
swiftSettings: swiftSettings
),
.target(
name: "ConsoleLogger",
dependencies: [
.product(name: "Logging", package: "swift-log"),
.target(name: "ConsoleKit"),
Comment thread
gwynne marked this conversation as resolved.
],
swiftSettings: swiftSettings
),
.testTarget(
name: "ConsoleLoggerTests",
dependencies: [
.target(name: "ConsoleLogger")
Comment thread
gwynne marked this conversation as resolved.
],
swiftSettings: swiftSettings
),
.executableTarget(
name: "ConsoleLoggerExample",
dependencies: [
.target(name: "ConsoleKit"),
.target(name: "ConsoleLogger"),
.product(name: "Logging", package: "swift-log"),
],
swiftSettings: swiftSettings
Expand All @@ -45,6 +63,11 @@ var swiftSettings: [SwiftSetting] {
[
.enableUpcomingFeature("ExistentialAny"),
.enableUpcomingFeature("MemberImportVisibility"),
.enableUpcomingFeature("ExistentialAny"),
.enableUpcomingFeature("InternalImportsByDefault"),
.enableUpcomingFeature("MemberImportVisibility"),
.enableUpcomingFeature("InferIsolatedConformances"),
//.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
.enableUpcomingFeature("ImmutableWeakCaptures"),
]
}
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<a href="https://discord.gg/vapor"><img src="https://design.vapor.codes/images/discordchat.svg" alt="Team Chat"></a>
<a href="LICENSE"><img src="https://design.vapor.codes/images/mitlicense.svg" alt="MIT License"></a>
<a href="https://github.com/vapor/console-kit/actions/workflows/test.yml"><img src="https://img.shields.io/github/actions/workflow/status/vapor/console-kit/test.yml?event=push&style=plastic&logo=github&label=tests&logoColor=%23ccc" alt="Continuous Integration"></a>
<a href="https://codecov.io/github/vapor/console-kit"><img src="https://img.shields.io/codecov/c/github/vapor/console-kit?style=plastic&logo=codecov&label=codecov"></a>
<a href="https://codecov.io/github/vapor/console-kit"><img src="https://img.shields.io/codecov/c/github/vapor/console-kit?style=plastic&logo=codecov&label=codecov" alt="Code Coverage"></a>
<a href="https://swift.org"><img src="https://design.vapor.codes/images/swift61up.svg" alt="Swift 6.1+"></a>
</p>

Expand Down Expand Up @@ -38,4 +38,14 @@ and add it to your target's dependencies:

* Utilities for sending text (including styles and colors, when supported) to a terminal.
* Utilities for reading input from a terminal.
* ``ConsoleLogger`` and ``ConsoleFragmentLogger``, [SwiftLog](https://github.com/apple/swift-log) `LogHandler` implementations for customizable logging to a console.
* ``ConsoleLogger``, a [SwiftLog](https://github.com/apple/swift-log) `LogHandler` implementation for customizable logging to a console.

### Logging

`ConsoleLogger` is a flexible logging backend for console applications, allowing developers to customize log output with various fragments, including timestamps, log levels, and source locations.

To use `ConsoleLogger`, add it to your target's dependencies:

```swift
.product(name: "ConsoleLogger", package: "console-kit")
```
2 changes: 1 addition & 1 deletion Sources/ConsoleKit/Activity/ProgressBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ extension ActivityIndicator where A == ProgressBar {
///
/// See ``ActivityIndicator/withActivityIndicator(refreshRate:_:)-(_,()->T)`` for more information.
@discardableResult
public func withActivityIndicator<T>(
public func withActivityIndicator<T: Sendable>(
refreshRate: Int = 40,
_ body: @Sendable (ActivityIndicator<ProgressBar>) async throws -> T
) async rethrows -> T {
Expand Down
2 changes: 1 addition & 1 deletion Sources/ConsoleKit/Clear/Console+Ephemeral.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ extension Console {
/// This method allows the ``Console`` implementation to record how many lines have been printed so
/// that ``Console/pushEphemeral()`` and ``Console/popEphemeral()`` knows how many lines to clear.
///
/// This method should only be used by ``Console`` implementations.
/// > Note: This method should only be used by ``Console`` implementations.
public func didOutputLines(count: Int) {
guard self.depth > 0 else {
// not in an ephemeral state
Expand Down
27 changes: 1 addition & 26 deletions Sources/ConsoleKit/Docs.docc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

* Utilities for sending text (including styles and colors, when supported) to a terminal.
* Utilities for reading input from a terminal.
* ``ConsoleLogger`` and ``ConsoleFragmentLogger``, [SwiftLog](https://github.com/apple/swift-log) `LogHandler` implementations for customizable logging to a console.

## Topics

Expand All @@ -37,28 +36,4 @@
- ``ActivityBar``
- ``LoadingBar``
- ``ProgressBar``
- ``CustomActivity``

### Logging

- ``ConsoleLogger``
- ``ConsoleFragmentLogger``
- ``LoggerFragment``
- ``LogRecord``
- ``FragmentOutput``
- ``IfMaxLevelFragment``
- ``AndFragment``
- ``LabelFragment``
- ``LevelFragment``
- ``LiteralFragment``
- ``SeparatorFragment``
- ``MessageFragment``
- ``MetadataFragment``
- ``SourceLocationFragment``
- ``LoggerSourceFragment``
- ``TimestampSource``
- ``SystemTimestampSource``
- ``TimestampFragment``
- ``defaultLoggerFragment()``
- ``timestampDefaultLoggerFragment(timestampSource:)``
- ``ConsoleKit/Logging``
- ``CustomActivity``
Loading