Skip to content

Commit

Permalink
Prepend plugin to log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
diptanu committed Feb 12, 2016
1 parent 3143ecc commit 2543bf2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions client.go
Expand Up @@ -139,7 +139,7 @@ func CleanupClients() {
}(client)
}

log.Println("[DEBUG] waiting for all plugin processes to complete...")
log.Println("[DEBUG] plugin: waiting for all plugin processes to complete...")
wg.Wait()
}

Expand Down Expand Up @@ -302,7 +302,7 @@ func (c *Client) Start() (addr net.Addr, err error) {
pidWait(pid)

// Log so we can see it
log.Printf("[DEBUG] reattached plugin process exited\n")
log.Printf("[DEBUG] plugin: reattached plugin process exited\n")

// Mark it
c.l.Lock()
Expand Down Expand Up @@ -336,7 +336,7 @@ func (c *Client) Start() (addr net.Addr, err error) {
cmd.Stderr = stderr_w
cmd.Stdout = stdout_w

log.Printf("[DEBUG] Starting plugin: %s %#v", cmd.Path, cmd.Args)
log.Printf("[DEBUG] plugin: starting plugin: %s %#v", cmd.Path, cmd.Args)
err = cmd.Start()
if err != nil {
return
Expand Down Expand Up @@ -370,7 +370,7 @@ func (c *Client) Start() (addr net.Addr, err error) {
cmd.Wait()

// Log and make sure to flush the logs write away
log.Printf("[DEBUG] %s: plugin process exited\n", cmd.Path)
log.Printf("[DEBUG] plugin: %s: plugin process exited\n", cmd.Path)
os.Stderr.Sync()

// Mark that we exited
Expand Down Expand Up @@ -417,7 +417,7 @@ func (c *Client) Start() (addr net.Addr, err error) {
timeout := time.After(c.config.StartTimeout)

// Start looking for the address
log.Printf("[DEBUG] Waiting for RPC address for: %s", cmd.Path)
log.Printf("[DEBUG] plugin: waiting for RPC address for: %s", cmd.Path)
select {
case <-timeout:
err = errors.New("timeout while waiting for plugin to start")
Expand Down Expand Up @@ -520,7 +520,7 @@ func (c *Client) logStderr(r io.Reader) {
c.config.Stderr.Write([]byte(line))

line = strings.TrimRightFunc(line, unicode.IsSpace)
log.Printf("[DEBUG] %s: %s", filepath.Base(c.config.Cmd.Path), line)
log.Printf("[DEBUG] plugin: %s: %s", filepath.Base(c.config.Cmd.Path), line)
}

if err == io.EOF {
Expand Down
2 changes: 1 addition & 1 deletion mux_broker.go
Expand Up @@ -80,7 +80,7 @@ func (m *MuxBroker) Accept(id uint32) (net.Conn, error) {
func (m *MuxBroker) AcceptAndServe(id uint32, v interface{}) {
conn, err := m.Accept(id)
if err != nil {
log.Printf("[ERR] Plugin acceptAndServe: %s", err)
log.Printf("[ERR] plugin: plugin acceptAndServe error: %s", err)
return
}

Expand Down
10 changes: 5 additions & 5 deletions rpc_server.go
Expand Up @@ -31,7 +31,7 @@ func (s *RPCServer) Accept(lis net.Listener) {
for {
conn, err := lis.Accept()
if err != nil {
log.Printf("[ERR] plugin server: %s", err)
log.Printf("[ERR] plugin: plugin server: %s", err)
return
}

Expand All @@ -47,7 +47,7 @@ func (s *RPCServer) ServeConn(conn io.ReadWriteCloser) {
mux, err := yamux.Server(conn, nil)
if err != nil {
conn.Close()
log.Printf("[ERR] plugin: %s", err)
log.Printf("[ERR] plugin: error creating yamux server: %s", err)
return
}

Expand All @@ -56,7 +56,7 @@ func (s *RPCServer) ServeConn(conn io.ReadWriteCloser) {
if err != nil {
mux.Close()
if err != io.EOF {
log.Printf("[ERR] plugin: %s", err)
log.Printf("[ERR] plugin: error accepting control connection: %s", err)
}

return
Expand Down Expand Up @@ -122,7 +122,7 @@ func (d *dispenseServer) Dispense(
go func() {
conn, err := d.broker.Accept(id)
if err != nil {
log.Printf("[ERR] Plugin dispense %s: %s", name, err)
log.Printf("[ERR] go-plugin: plugin dispense error: %s: %s", name, err)
return
}

Expand All @@ -135,7 +135,7 @@ func (d *dispenseServer) Dispense(
func serve(conn io.ReadWriteCloser, name string, v interface{}) {
server := rpc.NewServer()
if err := server.RegisterName(name, v); err != nil {
log.Printf("[ERR] Plugin dispense: %s", err)
log.Printf("[ERR] go-plugin: plugin dispense error: %s", err)
return
}

Expand Down
6 changes: 3 additions & 3 deletions server.go
Expand Up @@ -93,7 +93,7 @@ func Serve(opts *ServeConfig) {
// Register a listener so we can accept a connection
listener, err := serverListener()
if err != nil {
log.Printf("[ERR] plugin init: %s", err)
log.Printf("[ERR] plugin: plugin init: %s", err)
return
}
defer listener.Close()
Expand All @@ -106,7 +106,7 @@ func Serve(opts *ServeConfig) {
}

// Output the address and service name to stdout so that core can bring it up.
log.Printf("Plugin address: %s %s\n",
log.Printf("[DEBUG] plugin: plugin address: %s %s\n",
listener.Addr().Network(), listener.Addr().String())
fmt.Printf("%d|%d|%s|%s\n",
CoreProtocolVersion,
Expand All @@ -124,7 +124,7 @@ func Serve(opts *ServeConfig) {
<-ch
newCount := atomic.AddInt32(&count, 1)
log.Printf(
"Received interrupt signal (count: %d). Ignoring.",
"[DEBUG] plugin: received interrupt signal (count: %d). Ignoring.",
newCount)
}
}()
Expand Down

0 comments on commit 2543bf2

Please sign in to comment.