Use github.com/golang/glog for all logging.

This commit is contained in:
Julius Volz 2013-08-12 17:18:02 +02:00
parent 83fb0a9a2d
commit aa5d251f8d
27 changed files with 117 additions and 112 deletions

43
main.go
View File

@ -15,12 +15,12 @@ package main
import (
"flag"
"log"
"os"
"os/signal"
"sync"
"time"
"github.com/golang/glog"
"github.com/prometheus/client_golang/extraction"
"github.com/prometheus/prometheus/config"
@ -28,7 +28,6 @@ import (
"github.com/prometheus/prometheus/retrieval"
"github.com/prometheus/prometheus/rules"
"github.com/prometheus/prometheus/storage/metric"
"github.com/prometheus/prometheus/web"
"github.com/prometheus/prometheus/web/api"
)
@ -91,7 +90,7 @@ func (p *prometheus) interruptHandler() {
<-notifier
log.Println("Received SIGINT; Exiting Gracefully...")
glog.Warning("Received SIGINT; Exiting gracefully...")
p.close()
os.Exit(0)
}
@ -169,15 +168,12 @@ func main() {
conf, err := config.LoadFromFile(*configFile)
if err != nil {
log.Fatalf("Error loading configuration from %s: %v", *configFile, err)
glog.Fatalf("Error loading configuration from %s: %v", *configFile, err)
}
ts, err := metric.NewTieredStorage(uint(*diskAppendQueueCapacity), 100, *arenaFlushInterval, *arenaTTL, *metricsStoragePath)
if err != nil {
log.Fatalf("Error opening storage: %s", err)
}
if ts == nil {
log.Fatalln("Nil tiered storage.")
glog.Fatal("Error opening storage:", err)
}
unwrittenSamples := make(chan *extraction.Result, *samplesQueueCapacity)
@ -196,9 +192,8 @@ func main() {
// Queue depth will need to be exposed
ruleManager := rules.NewRuleManager(unwrittenSamples, notifications, conf.EvaluationInterval(), ts)
err = ruleManager.AddRulesFromConfig(conf)
if err != nil {
log.Fatalf("Error loading rule files: %v", err)
if err := ruleManager.AddRulesFromConfig(conf); err != nil {
glog.Fatal("Error loading rule files:", err)
}
go ruleManager.Run()
@ -273,56 +268,56 @@ func main() {
go func() {
for _ = range prometheus.headCompactionTimer.C {
log.Println("Starting head compaction...")
glog.Info("Starting head compaction...")
err := prometheus.compact(*headAge, *headGroupSize)
if err != nil {
log.Printf("could not compact due to %s", err)
glog.Error("could not compact:", err)
}
log.Println("Done")
glog.Info("Done")
}
}()
go func() {
for _ = range prometheus.bodyCompactionTimer.C {
log.Println("Starting body compaction...")
glog.Info("Starting body compaction...")
err := prometheus.compact(*bodyAge, *bodyGroupSize)
if err != nil {
log.Printf("could not compact due to %s", err)
glog.Error("could not compact:", err)
}
log.Println("Done")
glog.Info("Done")
}
}()
go func() {
for _ = range prometheus.tailCompactionTimer.C {
log.Println("Starting tail compaction...")
glog.Info("Starting tail compaction...")
err := prometheus.compact(*tailAge, *tailGroupSize)
if err != nil {
log.Printf("could not compact due to %s", err)
glog.Error("could not compact:", err)
}
log.Println("Done")
glog.Info("Done")
}
}()
go func() {
for _ = range prometheus.deletionTimer.C {
log.Println("Starting deletion of stale values...")
glog.Info("Starting deletion of stale values...")
err := prometheus.delete(*deleteAge, deletionBatchSize)
if err != nil {
log.Printf("could not delete due to %s", err)
glog.Error("could not delete:", err)
}
log.Println("Done")
glog.Info("Done")
}
}()
go func() {
err := webService.ServeForever()
if err != nil {
log.Fatal(err)
glog.Fatal(err)
}
}()

View File

@ -19,11 +19,12 @@ import (
"flag"
"io"
"io/ioutil"
"log"
"net/http"
"text/template"
"time"
"github.com/golang/glog"
clientmodel "github.com/prometheus/client_golang/model"
"github.com/prometheus/prometheus/utility"
@ -95,7 +96,7 @@ func interpolateMessage(msg string, labels clientmodel.LabelSet, value clientmod
"{{$value := .Value}}"
if _, err := t.Parse(defs + msg); err != nil {
log.Println("Error parsing template:", err)
glog.Warning("Error parsing template:", err)
return msg
}
@ -114,7 +115,7 @@ func interpolateMessage(msg string, labels clientmodel.LabelSet, value clientmod
var buf bytes.Buffer
if err := t.Execute(&buf, &tmplData); err != nil {
log.Println("Error executing template:", err)
glog.Warning("Error executing template:", err)
return msg
}
return buf.String()
@ -176,7 +177,7 @@ func (n *NotificationHandler) Run() {
for reqs := range n.pendingNotifications {
if n.alertmanagerUrl == "" {
log.Println("No alert manager configured, not dispatching notification")
glog.Warning("No alert manager configured, not dispatching notification")
notificationsCount.Increment(map[string]string{result: dropped})
continue
}
@ -186,7 +187,7 @@ func (n *NotificationHandler) Run() {
recordOutcome(time.Since(begin), err)
if err != nil {
log.Println("Error sending notification:", err)
glog.Error("Error sending notification:", err)
}
}
}

View File

@ -16,12 +16,12 @@ package retrieval
import (
"bytes"
"fmt"
"log"
"net/http"
"os"
"strings"
"time"
"github.com/golang/glog"
"github.com/prometheus/client_golang/extraction"
clientmodel "github.com/prometheus/client_golang/model"
@ -303,7 +303,7 @@ func (t *target) GlobalAddress() string {
address := t.address
hostname, err := os.Hostname()
if err != nil {
log.Printf("Couldn't get hostname: %s, returning target.Address()", err)
glog.Warning("Couldn't get hostname: %s, returning target.Address()", err)
return address
}
for _, localhostRepresentation := range localhostRepresentations {

View File

@ -15,13 +15,14 @@ package retrieval
import (
"fmt"
"log"
"net/url"
"time"
"github.com/golang/glog"
"github.com/miekg/dns"
clientmodel "github.com/prometheus/client_golang/model"
"github.com/miekg/dns"
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/utility"
)
@ -77,7 +78,7 @@ func (p *sdTargetProvider) Targets() ([]Target, error) {
for _, record := range response.Answer {
addr, ok := record.(*dns.SRV)
if !ok {
log.Printf("%s is not a valid SRV record", addr)
glog.Warning("%s is not a valid SRV record", addr)
continue
}
// Remove the final dot from rooted DNS names to make them look more usual.

View File

@ -14,10 +14,11 @@
package retrieval
import (
"log"
"time"
"github.com/golang/glog"
"github.com/prometheus/client_golang/extraction"
clientmodel "github.com/prometheus/client_golang/model"
"github.com/prometheus/prometheus/config"
@ -65,7 +66,7 @@ func (m *targetManager) TargetPoolForJob(job config.JobConfig) *TargetPool {
}
targetPool = NewTargetPool(m, provider)
log.Printf("Pool for job %s does not exist; creating and starting...", job.GetName())
glog.Infof("Pool for job %s does not exist; creating and starting...", job.GetName())
interval := job.ScrapeInterval()
m.poolsByJob[job.GetName()] = targetPool

View File

@ -14,11 +14,11 @@
package retrieval
import (
"log"
"sort"
"sync"
"time"
"github.com/golang/glog"
"github.com/prometheus/client_golang/extraction"
)
@ -63,7 +63,7 @@ func (p *TargetPool) Run(results chan<- *extraction.Result, interval time.Durati
case newTargets := <-p.replaceTargetsQueue:
p.replaceTargets(newTargets)
case <-p.done:
log.Printf("TargetPool exiting...")
glog.Info("TargetPool exiting...")
return
}
}
@ -127,7 +127,7 @@ func (p *TargetPool) runIteration(results chan<- *extraction.Result, interval ti
if p.targetProvider != nil {
targets, err := p.targetProvider.Targets()
if err != nil {
log.Printf("Error looking up targets, keeping old list: %s", err)
glog.Warning("Error looking up targets, keeping old list: %s", err)
} else {
p.ReplaceTargets(targets)
}

View File

@ -17,11 +17,12 @@ import (
"errors"
"fmt"
"hash/fnv"
"log"
"math"
"sort"
"time"
"github.com/golang/glog"
clientmodel "github.com/prometheus/client_golang/model"
"github.com/prometheus/prometheus/stats"
@ -401,7 +402,7 @@ func (node *VectorAggregation) Eval(timestamp time.Time, view *viewAdapter) Vect
func (node *VectorLiteral) Eval(timestamp time.Time, view *viewAdapter) Vector {
values, err := view.GetValueAtTime(node.fingerprints, timestamp)
if err != nil {
log.Println("Unable to get vector values:", err)
glog.Error("Unable to get vector values:", err)
return Vector{}
}
return values
@ -589,7 +590,7 @@ func (node *MatrixLiteral) Eval(timestamp time.Time, view *viewAdapter) Matrix {
}
values, err := view.GetRangeValues(node.fingerprints, interval)
if err != nil {
log.Println("Unable to get values for vector interval:", err)
glog.Error("Unable to get values for vector interval:", err)
return Matrix{}
}
return values
@ -602,7 +603,7 @@ func (node *MatrixLiteral) EvalBoundaries(timestamp time.Time, view *viewAdapter
}
values, err := view.GetBoundaryValues(node.fingerprints, interval)
if err != nil {
log.Printf("Unable to get boundary values for vector interval:", err)
glog.Error("Unable to get boundary values for vector interval:", err)
return Matrix{}
}
return values

View File

@ -14,9 +14,10 @@
package ast
import (
"log"
"time"
"github.com/golang/glog"
clientmodel "github.com/prometheus/client_golang/model"
"github.com/prometheus/prometheus/stats"
@ -56,7 +57,7 @@ func (analyzer *QueryAnalyzer) Visit(node Node) {
case *VectorLiteral:
fingerprints, err := analyzer.storage.GetFingerprintsForLabelSet(n.labels)
if err != nil {
log.Printf("Error getting fingerprints for labelset %v: %v", n.labels, err)
glog.Errorf("Error getting fingerprints for labelset %v: %v", n.labels, err)
return
}
n.fingerprints = fingerprints
@ -68,7 +69,7 @@ func (analyzer *QueryAnalyzer) Visit(node Node) {
case *MatrixLiteral:
fingerprints, err := analyzer.storage.GetFingerprintsForLabelSet(n.labels)
if err != nil {
log.Printf("Error getting fingerprints for labelset %v: %v", n.labels, err)
glog.Errorf("Error getting fingerprints for labelset %v: %v", n.labels, err)
return
}
n.fingerprints = fingerprints

View File

@ -18,10 +18,11 @@ import (
"errors"
"fmt"
"io"
"log"
"os"
"strings"
"github.com/golang/glog"
"github.com/prometheus/prometheus/rules/ast"
)
@ -69,7 +70,7 @@ func (lexer *RulesLexer) getChar() byte {
}
lexer.current = b
} else if err != io.EOF {
log.Fatal(err)
glog.Fatal(err)
}
return lexer.current
}

View File

@ -14,11 +14,12 @@
package rules
import (
"log"
"sync"
"time"
"github.com/golang/glog"
"github.com/prometheus/client_golang/extraction"
clientmodel "github.com/prometheus/client_golang/model"
"github.com/prometheus/prometheus/config"
@ -74,7 +75,7 @@ func (m *ruleManager) Run() {
m.runIteration(m.results)
evalDurations.Add(map[string]string{intervalKey: m.interval.String()}, float64(time.Since(start)/time.Millisecond))
case <-m.done:
log.Printf("RuleManager exiting...")
glog.Info("RuleManager exiting...")
break
}
}

View File

@ -23,12 +23,12 @@ import (
clientmodel "github.com/prometheus/client_golang/model"
dto "github.com/prometheus/prometheus/model/generated"
"github.com/prometheus/prometheus/coding"
"github.com/prometheus/prometheus/storage"
"github.com/prometheus/prometheus/storage/raw"
"github.com/prometheus/prometheus/storage/raw/leveldb"
dto "github.com/prometheus/prometheus/model/generated"
)
// CurationState contains high-level curation state information for the

View File

@ -19,11 +19,11 @@ import (
clientmodel "github.com/prometheus/client_golang/model"
dto "github.com/prometheus/prometheus/model/generated"
"github.com/prometheus/prometheus/coding"
"github.com/prometheus/prometheus/coding/indexable"
"github.com/prometheus/prometheus/storage/raw/leveldb"
dto "github.com/prometheus/prometheus/model/generated"
)
// diskFrontier describes an on-disk store of series to provide a

View File

@ -20,12 +20,12 @@ import (
clientmodel "github.com/prometheus/client_golang/model"
dto "github.com/prometheus/prometheus/model/generated"
"github.com/prometheus/prometheus/storage"
"github.com/prometheus/prometheus/storage/raw"
"github.com/prometheus/prometheus/storage/raw/leveldb"
"github.com/prometheus/prometheus/utility"
dto "github.com/prometheus/prometheus/model/generated"
)
type FingerprintMetricMapping map[clientmodel.Fingerprint]clientmodel.Metric

View File

@ -16,21 +16,21 @@ package metric
import (
"flag"
"fmt"
"log"
"sort"
"sync"
"time"
"code.google.com/p/goprotobuf/proto"
"github.com/golang/glog"
clientmodel "github.com/prometheus/client_golang/model"
dto "github.com/prometheus/prometheus/model/generated"
"github.com/prometheus/prometheus/storage"
"github.com/prometheus/prometheus/storage/raw"
"github.com/prometheus/prometheus/storage/raw/leveldb"
"github.com/prometheus/prometheus/utility"
dto "github.com/prometheus/prometheus/model/generated"
)
const sortConcurrency = 2
@ -104,7 +104,7 @@ func (l *LevelDBMetricPersistence) Close() {
closer.Close()
case errorCloser:
if err := closer.Close(); err != nil {
log.Println("anomaly closing:", err)
glog.Error("Error closing persistence:", err)
}
}
}
@ -236,7 +236,7 @@ func NewLevelDBMetricPersistence(baseDirectory string) (*LevelDBMetricPersistenc
if !workers.Wait() {
for _, err := range workers.Errors() {
log.Printf("Could not open storage due to %s", err)
glog.Error("Could not open storage:", err)
}
return nil, fmt.Errorf("Unable to open metric persistence.")

View File

@ -21,10 +21,10 @@ import (
clientmodel "github.com/prometheus/client_golang/model"
dto "github.com/prometheus/prometheus/model/generated"
"github.com/prometheus/prometheus/storage/raw"
"github.com/prometheus/prometheus/storage/raw/leveldb"
dto "github.com/prometheus/prometheus/model/generated"
)
// processor models a post-processing agent that performs work given a sample

View File

@ -22,10 +22,10 @@ import (
clientmodel "github.com/prometheus/client_golang/model"
"github.com/prometheus/prometheus/storage/raw/leveldb"
dto "github.com/prometheus/prometheus/model/generated"
fixture "github.com/prometheus/prometheus/storage/raw/leveldb/test"
"github.com/prometheus/prometheus/storage/raw/leveldb"
)
type curationState struct {

View File

@ -21,9 +21,9 @@ import (
clientmodel "github.com/prometheus/client_golang/model"
dto "github.com/prometheus/prometheus/model/generated"
"github.com/prometheus/prometheus/coding/indexable"
dto "github.com/prometheus/prometheus/model/generated"
)
// SampleKey models the business logic around the data-transfer object

View File

@ -24,11 +24,11 @@ import (
clientmodel "github.com/prometheus/client_golang/model"
dto "github.com/prometheus/prometheus/model/generated"
"github.com/prometheus/prometheus/coding"
"github.com/prometheus/prometheus/coding/indexable"
"github.com/prometheus/prometheus/utility/test"
dto "github.com/prometheus/prometheus/model/generated"
)
const stochasticMaximumVariance = 8

View File

@ -15,12 +15,11 @@ package metric
import (
"fmt"
"log"
"sort"
"sync"
"time"
dto "github.com/prometheus/prometheus/model/generated"
"github.com/golang/glog"
clientmodel "github.com/prometheus/client_golang/model"
@ -28,6 +27,8 @@ import (
"github.com/prometheus/prometheus/coding/indexable"
"github.com/prometheus/prometheus/stats"
"github.com/prometheus/prometheus/storage/raw/leveldb"
dto "github.com/prometheus/prometheus/model/generated"
)
type chunk Values
@ -175,7 +176,7 @@ func (t *TieredStorage) drain(drained chan<- bool) {
t.state = tieredStorageDraining
log.Println("Triggering drain...")
glog.Info("Triggering drain...")
t.draining <- (drained)
}
@ -269,7 +270,7 @@ func (t *TieredStorage) Flush() {
func (t *TieredStorage) flushMemory(ttl time.Duration) {
flushOlderThan := time.Now().Add(-1 * ttl)
log.Println("Flushing...")
glog.Info("Flushing samples to disk...")
t.memoryArena.Flush(flushOlderThan, t.appendToDiskQueue)
queueLength := len(t.appendToDiskQueue)
@ -280,11 +281,11 @@ func (t *TieredStorage) flushMemory(ttl time.Duration) {
samples = append(samples, chunk...)
}
log.Printf("Writing %d samples...", len(samples))
glog.Infof("Writing %d samples...", len(samples))
t.DiskStorage.AppendSamples(samples)
}
log.Println("Done flushing.")
glog.Info("Done flushing.")
}
func (t *TieredStorage) Close() {
@ -373,7 +374,7 @@ func (t *TieredStorage) renderView(viewJob viewJob) {
for _, scanJob := range scans {
old, err := t.seriesTooOld(scanJob.fingerprint, *scanJob.operations[0].CurrentTime())
if err != nil {
log.Printf("Error getting watermark from cache for %s: %s", scanJob.fingerprint, err)
glog.Errorf("Error getting watermark from cache for %s: %s", scanJob.fingerprint, err)
continue
}
if old {

View File

@ -22,11 +22,11 @@ import (
clientmodel "github.com/prometheus/client_golang/model"
dto "github.com/prometheus/prometheus/model/generated"
"github.com/prometheus/prometheus/storage"
"github.com/prometheus/prometheus/storage/raw"
"github.com/prometheus/prometheus/storage/raw/leveldb"
dto "github.com/prometheus/prometheus/model/generated"
)
// unsafe.Sizeof(watermarks{})

View File

@ -16,10 +16,10 @@ package leveldb
import (
"code.google.com/p/goprotobuf/proto"
dto "github.com/prometheus/prometheus/model/generated"
"github.com/prometheus/prometheus/storage/raw"
"github.com/prometheus/prometheus/storage/raw/leveldb"
dto "github.com/prometheus/prometheus/model/generated"
)
var existenceValue = new(dto.MembershipIndexValue)

View File

@ -22,16 +22,16 @@ import (
"encoding/csv"
"flag"
"fmt"
"log"
"os"
"strconv"
"code.google.com/p/goprotobuf/proto"
dto "github.com/prometheus/prometheus/model/generated"
"github.com/golang/glog"
"github.com/prometheus/prometheus/storage"
"github.com/prometheus/prometheus/storage/metric"
dto "github.com/prometheus/prometheus/model/generated"
)
var (
@ -95,12 +95,12 @@ func main() {
flag.Parse()
if storageRoot == nil || *storageRoot == "" {
log.Fatal("Must provide a path...")
glog.Fatal("Must provide a path...")
}
persistence, err := metric.NewLevelDBMetricPersistence(*storageRoot)
if err != nil {
log.Fatal(err)
glog.Fatal(err)
}
defer persistence.Close()
@ -110,13 +110,13 @@ func main() {
entire, err := persistence.MetricSamples.ForEach(dumper, dumper, dumper)
if err != nil {
log.Fatalf("Error dumping samples: %s", err)
glog.Fatal("Error dumping samples:", err)
}
if !entire {
log.Fatalf("Didn't scan entire corpus")
glog.Fatal("Didn't scan entire corpus")
}
dumper.Flush()
if err = dumper.Error(); err != nil {
log.Fatalf("Error flushing CSV: %s", err)
glog.Fatal("Error flushing CSV:", err)
}
}

View File

@ -19,8 +19,9 @@ package main
import (
"flag"
"github.com/prometheus/prometheus/storage/metric"
"log"
"time"
"github.com/golang/glog"
)
var (
@ -31,21 +32,21 @@ func main() {
flag.Parse()
if storageRoot == nil || *storageRoot == "" {
log.Fatal("Must provide a path...")
glog.Fatal("Must provide a path...")
}
persistences, err := metric.NewLevelDBMetricPersistence(*storageRoot)
if err != nil {
log.Fatal(err)
glog.Fatal(err)
}
defer persistences.Close()
start := time.Now()
log.Printf("Starting compaction...")
glog.Info("Starting compaction...")
size, _ := persistences.Sizes()
log.Printf("Original Size: %d", size)
glog.Info("Original Size:", size)
persistences.Prune()
log.Printf("Finished in %s", time.Since(start))
glog.Info("Finished in", time.Since(start))
size, _ = persistences.Sizes()
log.Printf("New Size: %d", size)
glog.Info("New Size:", size)
}

View File

@ -19,7 +19,8 @@ package main
import (
"flag"
"fmt"
"log"
"github.com/golang/glog"
"github.com/prometheus/prometheus/rules"
)
@ -30,12 +31,12 @@ func main() {
flag.Parse()
if *ruleFile == "" {
log.Fatal("Must provide a rule file path")
glog.Fatal("Must provide a rule file path")
}
rules, err := rules.LoadRulesFromFile(*ruleFile)
if err != nil {
log.Fatalf("Error loading rule file %s: %s", *ruleFile, err)
glog.Fatalf("Error loading rule file %s: %s", *ruleFile, err)
}
fmt.Printf("Successfully loaded %d rules:\n\n", len(rules))

View File

@ -16,12 +16,12 @@ package api
import (
"encoding/json"
"errors"
"log"
"net/http"
"sort"
"time"
"code.google.com/p/gorest"
"github.com/golang/glog"
clientmodel "github.com/prometheus/client_golang/model"
@ -59,7 +59,7 @@ func (serv MetricsService) Query(expr string, asText string) string {
queryStats := stats.NewTimerGroup()
result := ast.EvalToString(exprNode, timestamp, format, serv.Storage, queryStats)
log.Printf("Instant query: %s\nQuery stats:\n%s\n", expr, queryStats)
glog.Infof("Instant query: %s\nQuery stats:\n%s\n", expr, queryStats)
return result
}
@ -113,7 +113,7 @@ func (serv MetricsService) QueryRange(expr string, end int64, duration int64, st
result := ast.TypedValueToJSON(matrix, "matrix")
jsonTimer.Stop()
log.Printf("Range query: %s\nQuery stats:\n%s\n", expr, queryStats)
glog.Infof("Range query: %s\nQuery stats:\n%s\n", expr, queryStats)
return result
}
@ -123,14 +123,14 @@ func (serv MetricsService) Metrics() string {
serv.setAccessControlHeaders(rb)
rb.SetContentType(gorest.Application_Json)
if err != nil {
log.Printf("Error loading metric names: %v", err)
glog.Error("Error loading metric names:", err)
rb.SetResponseCode(http.StatusInternalServerError)
return err.Error()
}
sort.Sort(metricNames)
resultBytes, err := json.Marshal(metricNames)
if err != nil {
log.Printf("Error marshalling metric names: %v", err)
glog.Error("Error marshalling metric names:", err)
rb.SetResponseCode(http.StatusInternalServerError)
return err.Error()
}

View File

@ -5,9 +5,10 @@ import (
"compress/gzip"
"fmt"
"io"
"log"
"net/http"
"strings"
"github.com/golang/glog"
)
const (
@ -50,7 +51,7 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
file, err := GetFile(StaticFiles, name)
if err != nil {
if err != io.EOF {
log.Printf("Could not get file: %s", err)
glog.Warning("Could not get file:", err)
}
w.WriteHeader(http.StatusNotFound)
return

View File

@ -17,14 +17,13 @@ import (
"flag"
"fmt"
"html/template"
"log"
"net"
"net/http"
"net/http/pprof"
"os"
"code.google.com/p/gorest"
"github.com/golang/glog"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/exp"
@ -77,7 +76,7 @@ func (w WebService) ServeForever() error {
exp.Handle("/user/", http.StripPrefix("/user/", http.FileServer(http.Dir(*userAssetsPath))))
}
log.Printf("listening on %s", *listenAddress)
glog.Info("listening on %s", *listenAddress)
return http.ListenAndServe(*listenAddress, exp.DefaultCoarseMux)
}
@ -94,14 +93,14 @@ func getEmbeddedTemplate(name string) (*template.Template, error) {
file, err := blob.GetFile(blob.TemplateFiles, "_base.html")
if err != nil {
log.Printf("Could not read base template: %s", err)
glog.Error("Could not read base template:", err)
return nil, err
}
t.Parse(string(file))
file, err = blob.GetFile(blob.TemplateFiles, name+".html")
if err != nil {
log.Printf("Could not read %s template: %s", name, err)
glog.Errorf("Could not read %s template: %s", name, err)
return nil, err
}
t.Parse(string(file))
@ -131,12 +130,12 @@ func getTemplate(name string) (t *template.Template, err error) {
func executeTemplate(w http.ResponseWriter, name string, data interface{}) {
tpl, err := getTemplate(name)
if err != nil {
log.Printf("Error preparing layout template: %s", err)
glog.Error("Error preparing layout template:", err)
return
}
err = tpl.Execute(w, data)
if err != nil {
log.Printf("Error executing template: %s", err)
glog.Error("Error executing template:", err)
}
}