Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/FluidGroup/Bulk
👨💻 Bulk is a library for buffering the objects. Pipeline(Sink) receives the object and emits the object bulked.
https://github.com/FluidGroup/Bulk
logger logging swift
Last synced: 2 months ago
JSON representation
👨💻 Bulk is a library for buffering the objects. Pipeline(Sink) receives the object and emits the object bulked.
- Host: GitHub
- URL: https://github.com/FluidGroup/Bulk
- Owner: FluidGroup
- License: mit
- Created: 2017-05-02T17:41:43.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2024-10-21T05:37:51.000Z (3 months ago)
- Last Synced: 2024-10-22T14:31:06.223Z (3 months ago)
- Topics: logger, logging, swift
- Language: Swift
- Homepage:
- Size: 684 KB
- Stars: 60
- Watchers: 5
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- Awesome-Swift-Packages - Bulk - 👨💻 Bulk is pipeline based powerful & flexible logging framework. (Logger)
README
# Bulk / BulkLogger
[![Version](https://img.shields.io/cocoapods/v/Bulk.svg?style=flat)](http://cocoapods.org/pods/Bulk)
![platforms](https://img.shields.io/badge/platforms-iOS%20%7C%20macOS%20%7C%20tvOS%20%7C%20watchOS%20%7C%20Linux-333333.svg)Bulk is a library for buffering the objects.
Pipeline(Sink) receives the object and emits the object bulked.## What is for?
To pack a lot of elements would be helpful in several cases.
For example, sending the analytics events for your products with in house API.- collect the many events
- pack it into one
- send these events as a set of events.## Bulk module
### Make a sink
We call the pipeline that receives the object as `Sink`.
`Sink` receives the objects and emits the bulked object to multiple targets.
1. Select the buffer.
To create a bulk, we can choose several types of the buffer.
Currently, Bulk provides 2 types below.- MemoryBuffer
- FileBufferIn this tutorial, we select MemoryBuffer.
2. Create the target
Target receives the bulked object from Sink.
Bulk does not privides default implemented Target.
For now, you need to create it.```swift
public protocol TargetType {associatedtype Element
func write(items: [Element])
}
``````swift
struct MyTarget: TargetType {func write(items: [Element]) {
print(items)
}
}
```And finally, create BulkSink object.
```swift
let sink = BulkSink(
buffer: MemoryBuffer.init(size: 10).asAny(),
targets: [
MyTarget().asAny()
]
)
```Send the objects
```swift
sink.send("A")
sink.send("B")
sink.send("C")
````sink` sends the bulked object when Buffer receives the objects up to the specified size (10 elements in the example).
## BulkLogger module
The Logger as a library on top of Bulk.
BulkLogger provies `Logger` object that wraps `Sink` inside.
```swift
let logger = Logger(context: "", sinks: [
BulkSink(
buffer: MemoryBuffer.init(size: 10).asAny(),
targets: [TargetUmbrella.init(
transform: LogBasicFormatter().format,
targets: [
LogConsoleTarget.init().asAny()
]
).asAny(),OSLogTarget(subsystem: "BulkDemo", category: "Demo").asAny()
]
)
.asAny()
])
```Logger object send the log data to 2 targets (LogConsoleTarget and OSLogTarget)
```swift
logger.verbose("Hello")
```# LICENSE
Bulk Framework is released under the MIT License.