Skip to content

Commit c7d0f8b

Browse files
authored
Merge pull request #7 from andig/log
Provide generic logging interface
2 parents 54e6799 + 0a315c2 commit c7d0f8b

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

client.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ import (
99
"fmt"
1010
)
1111

12+
// logger is the interface to the required logging functions
13+
type logger interface {
14+
Printf(format string, v ...interface{})
15+
}
16+
1217
// ClientHandler is the interface that groups the Packager and Transporter methods.
1318
type ClientHandler interface {
1419
Packager

serial.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package modbus
66

77
import (
88
"io"
9-
"log"
109
"sync"
1110
"time"
1211

@@ -24,7 +23,7 @@ type serialPort struct {
2423
// Serial port configuration.
2524
serial.Config
2625

27-
Logger *log.Logger
26+
Logger logger
2827
IdleTimeout time.Duration
2928

3029
mu sync.Mutex

tcpclient.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"encoding/binary"
99
"fmt"
1010
"io"
11-
"log"
1211
"net"
1312
"sync"
1413
"sync/atomic"
@@ -133,7 +132,7 @@ type tcpTransporter struct {
133132
// Recovery timeout if the protocol is malformed, e.g. wrong transaction ID
134133
ProtocolRecoveryTimeout time.Duration
135134
// Transmission logger
136-
Logger *log.Logger
135+
Logger logger
137136

138137
// TCP connection
139138
mu sync.Mutex

0 commit comments

Comments
 (0)