aboutsummaryrefslogtreecommitdiffstats
path: root/lib/socket.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2022-11-27 11:29:34 +0100
committerRobin Jarry <robin@jarry.cc>2022-12-02 22:10:49 +0100
commit23a05d17ac1d23466ff73efa19576d43d06efe4b (patch)
tree49986587a62bdd89eb06ffa2aadf05f6d45cb3e7 /lib/socket.go
parent70f46757449c8f24b818f4dfc5dcb87da7e327d6 (diff)
downloadaerc-23a05d17ac1d23466ff73efa19576d43d06efe4b.tar.gz
logging: rename package to log
Use the same name than the builtin "log" package. That way, we do not risk logging in the wrong place. Suggested-by: Tim Culverhouse <tim@timculverhouse.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bence Ferdinandy <bence@ferdinandy.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'lib/socket.go')
-rw-r--r--lib/socket.go30
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/socket.go b/lib/socket.go
index 1cfd0583..5a41d910 100644
--- a/lib/socket.go
+++ b/lib/socket.go
@@ -12,7 +12,7 @@ import (
"sync/atomic"
"time"
- "git.sr.ht/~rjarry/aerc/logging"
+ "git.sr.ht/~rjarry/aerc/log"
"github.com/kyoh86/xdg"
)
@@ -28,7 +28,7 @@ func StartServer() (*AercServer, error) {
if err := ConnectAndExec(""); err != nil {
os.Remove(sockpath)
}
- logging.Debugf("Starting Unix server: %s", sockpath)
+ log.Debugf("Starting Unix server: %s", sockpath)
l, err := net.Listen("unix", sockpath)
if err != nil {
return nil, err
@@ -36,7 +36,7 @@ func StartServer() (*AercServer, error) {
as := &AercServer{listener: l}
// TODO: stash clients and close them on exit... bleh racey
go func() {
- defer logging.PanicHandler()
+ defer log.PanicHandler()
for {
conn, err := l.Accept()
@@ -46,12 +46,12 @@ func StartServer() (*AercServer, error) {
// TODO: Something more useful, in some
// cases, on wednesdays, after 2 PM,
// I guess?
- logging.Errorf("Closing Unix server: %v", err)
+ log.Errorf("Closing Unix server: %v", err)
}
return
}
go func() {
- defer logging.PanicHandler()
+ defer log.PanicHandler()
as.handleClient(conn)
}()
@@ -68,23 +68,23 @@ var lastId int64 = 0 // access via atomic
func (as *AercServer) handleClient(conn net.Conn) {
clientId := atomic.AddInt64(&lastId, 1)
- logging.Debugf("unix:%d accepted connection", clientId)
+ log.Debugf("unix:%d accepted connection", clientId)
scanner := bufio.NewScanner(conn)
err := conn.SetDeadline(time.Now().Add(1 * time.Minute))
if err != nil {
- logging.Errorf("failed to set deadline: %v", err)
+ log.Errorf("failed to set deadline: %v", err)
}
for scanner.Scan() {
err = conn.SetDeadline(time.Now().Add(1 * time.Minute))
if err != nil {
- logging.Errorf("failed to update deadline: %v", err)
+ log.Errorf("failed to update deadline: %v", err)
}
msg := scanner.Text()
- logging.Tracef("unix:%d got message %s", clientId, msg)
+ log.Tracef("unix:%d got message %s", clientId, msg)
if !strings.ContainsRune(msg, ':') {
_, innererr := conn.Write([]byte("error: invalid command\n"))
if innererr != nil {
- logging.Errorf("failed to write error message: %v", innererr)
+ log.Errorf("failed to write error message: %v", innererr)
}
continue
}
@@ -96,14 +96,14 @@ func (as *AercServer) handleClient(conn net.Conn) {
if err != nil {
_, innererr := conn.Write([]byte(fmt.Sprintf("error: %v\n", err)))
if innererr != nil {
- logging.Errorf("failed to write error message: %v", innererr)
+ log.Errorf("failed to write error message: %v", innererr)
}
break
}
if as.OnMailto != nil {
err = as.OnMailto(mailto)
if err != nil {
- logging.Errorf("mailto failed: %v", err)
+ log.Errorf("mailto failed: %v", err)
}
}
case "mbox":
@@ -114,16 +114,16 @@ func (as *AercServer) handleClient(conn net.Conn) {
if err != nil {
_, err = conn.Write([]byte(fmt.Sprintf("result: %v\n", err)))
if err != nil {
- logging.Errorf("failed to send error: %v")
+ log.Errorf("failed to send error: %v")
}
} else {
_, err = conn.Write([]byte("result: success\n"))
if err != nil {
- logging.Errorf("failed to send successmessage: %v")
+ log.Errorf("failed to send successmessage: %v")
}
}
}
- logging.Tracef("unix:%d closed connection", clientId)
+ log.Tracef("unix:%d closed connection", clientId)
}
func ConnectAndExec(msg string) error {