@@ -11,12 +11,12 @@ import OSLog
1111import Pulse
1212#endif
1313
14- protocol RemoteLoggerConnectionDelegate : AnyObject {
14+ public protocol RemoteLoggerConnectionDelegate : AnyObject {
1515 func connection( _ connection: RemoteLogger . Connection , didChangeState newState: NWConnection . State )
1616 func connection( _ connection: RemoteLogger . Connection , didReceiveEvent event: RemoteLogger . Connection . Event )
1717}
1818
19- extension RemoteLogger {
19+ public extension RemoteLogger {
2020 final class Connection {
2121 var endpoint : NWEndpoint { connection. endpoint }
2222 private let connection : NWConnection
@@ -31,14 +31,15 @@ extension RemoteLogger {
3131 self . init ( NWConnection ( to: endpoint, using: parameters) )
3232 }
3333
34- init ( _ connection: NWConnection ) {
34+ public init ( _ connection: NWConnection , delegate : RemoteLoggerConnectionDelegate ? = nil ) {
3535 self . connection = connection
36+ self . delegate = delegate
3637
3738 let isLogEnabled = UserDefaults . standard. bool ( forKey: " com.github.kean.pulse.debug " )
3839 self . log = isLogEnabled ? OSLog ( subsystem: " com.github.kean.pulse " , category: " RemoteLogger " ) : . disabled
3940 }
40-
41- func start( on queue: DispatchQueue ) {
41+
42+ public func start( on queue: DispatchQueue ) {
4243 connection. stateUpdateHandler = { [ weak self] state in
4344 guard let self = self else { return }
4445 DispatchQueue . main. async {
@@ -49,15 +50,15 @@ extension RemoteLogger {
4950 connection. start ( queue: queue)
5051 }
5152
52- enum Event {
53+ public enum Event {
5354 case packet( Packet )
5455 case error( Error )
5556 case completed
5657 }
5758
58- struct Packet {
59- let code : UInt8
60- let body : Data
59+ public struct Packet {
60+ public let code : UInt8
61+ public let body : Data
6162 }
6263
6364 private func receive( ) {
@@ -130,7 +131,7 @@ extension RemoteLogger {
130131 }
131132 }
132133
133- func send( code: UInt8 , data: Data ) {
134+ public func send( code: UInt8 , data: Data ) {
134135 do {
135136 let data = try encode ( code: code, body: data)
136137 let log = self . log
@@ -144,7 +145,7 @@ extension RemoteLogger {
144145 }
145146 }
146147
147- func send< T: Encodable > ( code: UInt8 , entity: T ) {
148+ public func send< T: Encodable > ( code: UInt8 , entity: T ) {
148149 do {
149150 let data = try JSONEncoder ( ) . encode ( entity)
150151 send ( code: code, data: data)
@@ -206,7 +207,7 @@ extension RemoteLogger {
206207 }
207208 }
208209
209- func cancel( ) {
210+ public func cancel( ) {
210211 connection. cancel ( )
211212 }
212213 }
0 commit comments