Skip to content

Commit 76a958f

Browse files
committed
improve startup-log
When given only a port (i.e. --web.listen-address=:9836, the default), the startup message read "Starting on http://:9836/". This is now changed to "Starting on http://0.0.0.0:9836/", which allows to click on the URL in the terminal (if the terminal supports this).
1 parent 0ab1b02 commit 76a958f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

exporter/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func LoadClientConfig(file string, verbose bool) (*Client, error) {
6363
}
6464

6565
func (c *Client) login() error {
66-
c.log.Debugf("performing login")
66+
c.log.Infof("performing login")
6767
ctx, cancel := context.WithTimeout(context.Background(), loginTimeout)
6868
defer cancel()
6969

exporter/exporter.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package exporter
22

33
import (
44
"encoding/json"
5+
"fmt"
56
"html/template"
67
"log"
8+
"net"
79
"net/http"
810

911
"github.com/julienschmidt/httprouter"
@@ -39,7 +41,14 @@ func (c *Client) Start(listenAddress, version string) error {
3941
router.GET("/apgroups/:ap_group/debug", c.debugHandler)
4042
router.GET("/apgroups/:ap_group/metrics", c.metricsHandler)
4143

42-
log.Printf("Starting exporter on http://%s/", listenAddress)
44+
var where string
45+
if host, port, err := net.SplitHostPort(listenAddress); err == nil && host == "" {
46+
where = fmt.Sprintf("http://0.0.0.0:%s/", port)
47+
} else {
48+
where = fmt.Sprintf("http://%s/", listenAddress)
49+
}
50+
51+
c.log.Infof("Starting exporter on %s", where)
4352

4453
return http.ListenAndServe(listenAddress, router)
4554
}

0 commit comments

Comments
 (0)