Index: /trunk/user.go
===================================================================
--- /trunk/user.go	(revision 492)
+++ /trunk/user.go	(revision 493)
@@ -174,5 +174,5 @@
 		if dur := time.Now().Sub(lastTry); dur < retryConnectDelay {
 			delay := retryConnectDelay - dur
-			net.user.srv.Logger.Printf("waiting %v before trying to reconnect to %q", delay.Truncate(time.Second), net.Addr)
+			net.user.logger.Printf("waiting %v before trying to reconnect to %q", delay.Truncate(time.Second), net.Addr)
 			time.Sleep(delay)
 		}
@@ -181,5 +181,5 @@
 		uc, err := connectToUpstream(net)
 		if err != nil {
-			net.user.srv.Logger.Printf("failed to connect to upstream server %q: %v", net.Addr, err)
+			net.user.logger.Printf("failed to connect to upstream server %q: %v", net.Addr, err)
 			net.user.events <- eventUpstreamConnectionError{net, fmt.Errorf("failed to connect: %v", err)}
 			continue
@@ -234,5 +234,5 @@
 	}
 	ch.Detached = true
-	net.user.srv.Logger.Printf("network %q: detaching channel %q", net.GetName(), ch.Name)
+	net.user.logger.Printf("network %q: detaching channel %q", net.GetName(), ch.Name)
 
 	if net.conn != nil {
@@ -257,5 +257,5 @@
 	}
 	ch.Detached = false
-	net.user.srv.Logger.Printf("network %q: attaching channel %q", net.GetName(), ch.Name)
+	net.user.logger.Printf("network %q: attaching channel %q", net.GetName(), ch.Name)
 
 	var uch *upstreamChannel
@@ -331,5 +331,5 @@
 
 	if err := net.user.srv.db.StoreClientDeliveryReceipts(net.ID, clientName, receipts); err != nil {
-		net.user.srv.Logger.Printf("failed to store delivery receipts for user %q, client %q, network %q: %v", net.user.Username, clientName, net.GetName(), err)
+		net.user.logger.Printf("failed to store delivery receipts for user %q, client %q, network %q: %v", net.user.Username, clientName, net.GetName(), err)
 	}
 }
@@ -337,5 +337,6 @@
 type user struct {
 	User
-	srv *Server
+	srv    *Server
+	logger Logger
 
 	events chan event
@@ -357,4 +358,6 @@
 
 func newUser(srv *Server, record *User) *user {
+	logger := &prefixLogger{srv.Logger, fmt.Sprintf("user %q: ", record.Username)}
+
 	var msgStore messageStore
 	if srv.LogPath != "" {
@@ -367,4 +370,5 @@
 		User:     *record,
 		srv:      srv,
+		logger:   logger,
 		events:   make(chan event, 64),
 		done:     make(chan struct{}),
@@ -419,5 +423,5 @@
 		if u.msgStore != nil {
 			if err := u.msgStore.Close(); err != nil {
-				u.srv.Logger.Printf("failed to close message store for user %q: %v", u.Username, err)
+				u.logger.Printf("failed to close message store for user %q: %v", u.Username, err)
 			}
 		}
@@ -427,5 +431,5 @@
 	networks, err := u.srv.db.ListNetworks(u.ID)
 	if err != nil {
-		u.srv.Logger.Printf("failed to list networks for user %q: %v", u.Username, err)
+		u.logger.Printf("failed to list networks for user %q: %v", u.Username, err)
 		return
 	}
@@ -435,5 +439,5 @@
 		channels, err := u.srv.db.ListChannels(record.ID)
 		if err != nil {
-			u.srv.Logger.Printf("failed to list channels for user %q, network %q: %v", u.Username, record.GetName(), err)
+			u.logger.Printf("failed to list channels for user %q, network %q: %v", u.Username, record.GetName(), err)
 			continue
 		}
@@ -445,5 +449,5 @@
 			receipts, err := u.srv.db.ListDeliveryReceipts(record.ID)
 			if err != nil {
-				u.srv.Logger.Printf("failed to load delivery receipts for user %q, network %q: %v", u.Username, network.GetName(), err)
+				u.logger.Printf("failed to load delivery receipts for user %q, network %q: %v", u.Username, network.GetName(), err)
 				return
 			}
@@ -515,5 +519,5 @@
 			uc.network.detach(c)
 			if err := uc.srv.db.StoreChannel(uc.network.ID, c); err != nil {
-				u.srv.Logger.Printf("failed to store updated detached channel %q: %v", c.Name, err)
+				u.logger.Printf("failed to store updated detached channel %q: %v", c.Name, err)
 			}
 		case eventDownstreamConnected:
@@ -580,5 +584,5 @@
 			return
 		default:
-			u.srv.Logger.Printf("received unknown event type: %T", e)
+			u.logger.Printf("received unknown event type: %T", e)
 		}
 	}
