Compare commits

..
5 Commits
Author SHA1 Message Date
Mikhail Kasianov 96a2f8a0fa Add Scout to the list of available backends (#337)
* Add Scout to the list of available backends

* Update README.md
2024-11-25 17:24:15 +00:00
Rick Newton-Rogers 0e75c43ee4 add .editorconfig file (#338) 2024-11-14 17:01:02 +01:00
LamTrinh.Dev 5f816304f9 Enhance swift codeblock at README.md (#327) 2024-11-13 13:38:45 +00:00
Franz Busch 1efe6f8129 Fix Windows warnings (#331)
# Motivation

Fixes https://github.com/apple/swift-log/issues/330.

We had a few warnings since we were using deprecated POSIX methods on Windows.

# Modification

Moves to the non-deprecated underscored methods.

# Result

Windows build is warning free.
2024-10-31 11:55:18 +01:00
Franz Busch ee1bfd3f47 [CI] Migrate to GHA (#328)
# Motivation

We want to modernize our CI.

# Modification

This PR migrates to GH actions and turns on all the right flags.

# Result

Modern CI.
2024-10-30 13:17:15 +00:00
3 changed files with 40 additions and 2 deletions

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
+4 -1
View File
@@ -85,6 +85,7 @@ 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?
@@ -169,7 +170,9 @@ public protocol LogHandler {
Instructing `SwiftLog` to use your logging backend as the one the whole application (including all libraries) should use is very simple:
LoggingSystem.bootstrap(MyLogHandler.init)
```swift
LoggingSystem.bootstrap(MyLogHandler.init)
```
### Implementation considerations
+28 -1
View File
@@ -1076,7 +1076,11 @@ 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)),
@@ -1094,11 +1098,20 @@ 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
@@ -1107,11 +1120,20 @@ 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")
}
}
@@ -1123,14 +1145,15 @@ 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)
@@ -1163,7 +1186,11 @@ class LoggingTest: XCTestCase {
body(writeFD!, readFD, readBuffer)
for fd in fds {
#if os(Windows)
_close(fd)
#else
close(fd)
#endif
}
}