Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide generic logging interface #7

Merged
merged 1 commit into from
Oct 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import (
"fmt"
)

// logger is the interface to the required logging functions
type logger interface {
Printf(format string, v ...interface{})
}

// ClientHandler is the interface that groups the Packager and Transporter methods.
type ClientHandler interface {
Packager
Expand Down
3 changes: 1 addition & 2 deletions serial.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package modbus

import (
"io"
"log"
"sync"
"time"

Expand All @@ -24,7 +23,7 @@ type serialPort struct {
// Serial port configuration.
serial.Config

Logger *log.Logger
Logger logger
IdleTimeout time.Duration

mu sync.Mutex
Expand Down
3 changes: 1 addition & 2 deletions tcpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"encoding/binary"
"fmt"
"io"
"log"
"net"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -135,7 +134,7 @@ type tcpTransporter struct {
// Idle timeout to close the connection
IdleTimeout time.Duration
// Transmission logger
Logger *log.Logger
Logger logger

// TCP connection
mu sync.Mutex
Expand Down