mirror of
https://github.com/apple/swift-log
synced 2026-11-23 03:44:22 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b20468db88 |
No files matched your search
@@ -1,8 +0,0 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
@@ -85,7 +85,6 @@ You can choose from one of the following backends to consume your logs. If you a
|
||||
| [CocoaLumberjack](https://github.com/CocoaLumberjack/CocoaLumberjack) | a fast & simple, yet powerful & flexible logging framework for macOS, iOS, tvOS and watchOS, which includes a logging backend for swift-log. |
|
||||
| [rwbutler/swift-log-ecs](https://github.com/rwbutler/swift-log-ecs) | a logging backend for logging in [ECS Log format](https://www.elastic.co/guide/en/ecs-logging/overview/current/intro.html). Compatible with [Vapor](https://github.com/vapor/vapor) and allows chaining of multiple LogHandlers. |
|
||||
| [ShipBook/swift-log-**shipbook**](https://github.com/ShipBook/swift-log-shipbook) | a logging backend that sends log entries to [Shipbook](https://www.shipbook.io) - Shipbook gives you the power to remotely gather, search and analyze your user logs and exceptions in the cloud, on a per-user & session basis. |
|
||||
| [kasianov-mikhail/scout](https://github.com/kasianov-mikhail/scout) | CloudKit as a log storage |
|
||||
| Your library? | [Get in touch!](https://forums.swift.org/c/server) |
|
||||
|
||||
## What is an API package?
|
||||
@@ -170,9 +169,7 @@ public protocol LogHandler {
|
||||
|
||||
Instructing `SwiftLog` to use your logging backend as the one the whole application (including all libraries) should use is very simple:
|
||||
|
||||
```swift
|
||||
LoggingSystem.bootstrap(MyLogHandler.init)
|
||||
```
|
||||
LoggingSystem.bootstrap(MyLogHandler.init)
|
||||
|
||||
### Implementation considerations
|
||||
|
||||
|
||||
@@ -1076,11 +1076,7 @@ class LoggingTest: XCTestCase {
|
||||
let testString = "hello\u{0} world"
|
||||
log.critical("\(testString)")
|
||||
|
||||
#if os(Windows)
|
||||
let size = _read(readFD, readBuffer, 256)
|
||||
#else
|
||||
let size = read(readFD, readBuffer, 256)
|
||||
#endif
|
||||
|
||||
let output = String(
|
||||
decoding: UnsafeRawBufferPointer(start: UnsafeRawPointer(readBuffer), count: numericCast(size)),
|
||||
@@ -1098,20 +1094,11 @@ class LoggingTest: XCTestCase {
|
||||
LoggingSystem.bootstrapInternal { StreamLogHandler(label: $0, stream: logStream) }
|
||||
Logger(label: "test").critical("test")
|
||||
|
||||
#if os(Windows)
|
||||
let size = _read(readFD, readBuffer, 256)
|
||||
#else
|
||||
let size = read(readFD, readBuffer, 256)
|
||||
#endif
|
||||
XCTAssertGreaterThan(size, -1, "expected flush")
|
||||
|
||||
logStream.flush()
|
||||
|
||||
#if os(Windows)
|
||||
let size2 = _read(readFD, readBuffer, 256)
|
||||
#else
|
||||
let size2 = read(readFD, readBuffer, 256)
|
||||
#endif
|
||||
XCTAssertEqual(size2, -1, "expected no flush")
|
||||
}
|
||||
// default flushing
|
||||
@@ -1120,20 +1107,11 @@ class LoggingTest: XCTestCase {
|
||||
LoggingSystem.bootstrapInternal { StreamLogHandler(label: $0, stream: logStream) }
|
||||
Logger(label: "test").critical("test")
|
||||
|
||||
#if os(Windows)
|
||||
let size = _read(readFD, readBuffer, 256)
|
||||
#else
|
||||
let size = read(readFD, readBuffer, 256)
|
||||
#endif
|
||||
XCTAssertEqual(size, -1, "expected no flush")
|
||||
|
||||
logStream.flush()
|
||||
|
||||
#if os(Windows)
|
||||
let size2 = _read(readFD, readBuffer, 256)
|
||||
#else
|
||||
let size2 = read(readFD, readBuffer, 256)
|
||||
#endif
|
||||
XCTAssertGreaterThan(size2, -1, "expected flush")
|
||||
}
|
||||
}
|
||||
@@ -1145,15 +1123,14 @@ class LoggingTest: XCTestCase {
|
||||
let err = _pipe($0.baseAddress, 256, _O_BINARY)
|
||||
XCTAssertEqual(err, 0, "_pipe failed \(err)")
|
||||
}
|
||||
let writeFD = _fdopen(fds[1], "w")
|
||||
#else
|
||||
fds.withUnsafeMutableBufferPointer { ptr in
|
||||
let err = pipe(ptr.baseAddress!)
|
||||
XCTAssertEqual(err, 0, "pipe failed \(err)")
|
||||
}
|
||||
let writeFD = fdopen(fds[1], "w")
|
||||
#endif
|
||||
|
||||
let writeFD = fdopen(fds[1], "w")
|
||||
let writeBuffer = UnsafeMutablePointer<Int8>.allocate(capacity: 256)
|
||||
defer {
|
||||
writeBuffer.deinitialize(count: 256)
|
||||
@@ -1186,11 +1163,7 @@ class LoggingTest: XCTestCase {
|
||||
body(writeFD!, readFD, readBuffer)
|
||||
|
||||
for fd in fds {
|
||||
#if os(Windows)
|
||||
_close(fd)
|
||||
#else
|
||||
close(fd)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user