Releases: brainfinance/StackdriverLogging
4.0.1
4.0.0
Modernize the implementation overall.
Changes
- Make the setup of
EventLoopGroup
unnecessary and switch the worker queue toNIOThreadPool
. - Use swift-system for file I/O.
- Remove StackdriverLogHandler.Factory, as there is no need for setup due to the default singleton NIOThreadPool.
Those who want customization can use their own NIOThreadPool.
Delete old test support files for Linux and additionally implement tests.
Many thanks @sidepelican 👍
3.1.0
3.0.0
This release replaces the old configuration parameter with a new StackdriverLogHandler.Destination
parameter when preparing the StackdriverLogHandler.Factory
.
This new destination parameter permits logging to stdout rather than always logging to a physical file. This will be very useful for people running their application under GCP Cloud Run as it automatically push stdout logs to stackdriver.
The factory preparation process has also been changed, the NIO dependencies used to write log entries are now created for you, but you must make sure to shutdown these dependencies before your application exists.
A typical bootstrap scenario will now look like this:
try StackdriverLogHandler.Factory.prepare(for: .stdout)
defer {
try! StackdriverLogHandler.Factory.syncShutdownGracefully()
}
let logLevel = Logger.Level.info
LoggingSystem.bootstrap { label -> LogHandler in
var logger = StackdriverLogHandler.Factory.make()
logger.logLevel = logLevel
return logger
}
2.2.2
Update readme
Remove mac os 10_14 dependency
2.2.1 Update package swift to remove the v10_14 dependency
Manual NIO dependencies factory's preparation
The responsibility of creating the NonBlockingFileIO
and the processing EventLoopGroup
has been moved to the client so that client's can cleanly shut them down when their application is shuts down.
What this means is that the LogHandler
factory must now be prepared with the NIO dependencies manually, they are no longer created automatically.
StackdriverLogHandlerFactory.prepare(with: configuration,
fileIO: fileIO,
eventLoopGroup: eventLoopGroup)
Logging timestamps automatically
Timestamps were only optionally attached to log entries, they are now always attached, otherwise, due to the async nature of the log writing, the timestamps shown by stackdriver are off.
Factory based instantiation + linux fixes
Changes:
- Fix crash related to
@autoreleasepool
on linux. - Fix log entries source location filepaths being fully logged, now only the relevant filepath information is logged.
- Add a configuration file from which you can control if timestamps are logged to your log file or not.
- Switch to a factory based instantiation system.
The bootstrapping now uses a factory and a config file, it looks like this:
try! StackdriverLogHandlerFactory.prepare(with: .init(logFilePath: "/var/log/my-app.log",
defaultLogLevel: .debug,
logTimestamps: true))
LoggingSystem.bootstrap { label in
return StackdriverLogHandlerFactory.make()
}
1.0.1
Remove the costly FileManager.fileExists
verification when instantiating a StackdriverLogHandler, checking if a FileHandle file has been moved or deleted is not of the Logger's concern.