Skip to content

Commit

Permalink
More loggo.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Penhey committed Apr 17, 2014
1 parent cabde2b commit c77cfec
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 60 deletions.
4 changes: 4 additions & 0 deletions charm/charm.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ import (
"errors"
"fmt"
"os"

"github.com/juju/loggo"
)

var logger = loggo.GetLogger("juju.charm")

// The Charm interface is implemented by any type that
// may be handled as a charm.
type Charm interface {
Expand Down
4 changes: 1 addition & 3 deletions charm/dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import (
"strconv"
"strings"
"syscall"

"launchpad.net/juju-core/log"
)

// The Dir type encapsulates access to data and operations
Expand Down Expand Up @@ -190,7 +188,7 @@ func (zp *zipPacker) visit(path string, fi os.FileInfo, err error) error {
if filepath.Dir(relpath) == "hooks" {
hookName := filepath.Base(relpath)
if _, ok := zp.hooks[hookName]; !fi.IsDir() && ok && mode&0100 == 0 {
log.Warningf("charm: making %q executable in charm", path)
logger.Warningf("making %q executable in charm", path)
perm = perm | 0100
}
}
Expand Down
7 changes: 3 additions & 4 deletions charm/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"path/filepath"
"strings"

"launchpad.net/juju-core/log"
"launchpad.net/juju-core/utils"
)

Expand Down Expand Up @@ -185,7 +184,7 @@ func (s *CharmStore) Info(curls ...Location) ([]*InfoResponse, error) {
if err != nil {
return nil, readErr
}
log.Errorf("%v Response body: %s", errMsg, body)
logger.Errorf("%v Response body: %s", errMsg, body)
return nil, errMsg
}
body, err := ioutil.ReadAll(resp.Body)
Expand Down Expand Up @@ -256,7 +255,7 @@ func (s *CharmStore) revisions(curls ...Location) (revisions []CharmRevision, er
revisions = make([]CharmRevision, len(infos))
for i, info := range infos {
for _, w := range info.Warnings {
log.Warningf("charm store reports for %q: %s", curls[i], w)
logger.Warningf("charm store reports for %q: %s", curls[i], w)
}
if info.Errors == nil {
revisions[i].Revision = info.Revision
Expand Down Expand Up @@ -503,7 +502,7 @@ func (r *LocalRepository) Get(curl *URL) (Charm, error) {
continue
}
if ch, err := Read(chPath); err != nil {
log.Warningf("failed to load charm at %q: %s", chPath, err)
logger.Warningf("failed to load charm at %q: %s", chPath, err)
} else if ch.Meta().Name == curl.Name {
if ch.Revision() == curl.Revision {
return ch, nil
Expand Down
6 changes: 4 additions & 2 deletions downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import (
"net/http"
"os"

"github.com/juju/loggo"
"launchpad.net/tomb"

"launchpad.net/juju-core/log"
"launchpad.net/juju-core/utils"
)

var logger = loggo.GetLogger("juju.downloader")

// Status represents the status of a completed download.
type Status struct {
// File holds the downloaded data on success.
Expand Down Expand Up @@ -114,7 +116,7 @@ func cleanTempFile(f *os.File) {
if f != nil {
f.Close()
if err := os.Remove(f.Name()); err != nil {
log.Warningf("downloader: cannot remove temp file %q: %v", f.Name(), err)
logger.Warningf("cannot remove temp file %q: %v", f.Name(), err)
}
}
}
6 changes: 4 additions & 2 deletions state/api/watcher/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
package watcher

import (
"github.com/juju/loggo"
"sync"

"launchpad.net/tomb"

"launchpad.net/juju-core/log"
"launchpad.net/juju-core/state/api/base"
"launchpad.net/juju-core/state/api/params"
)

var logger = loggo.GetLogger("juju.state.api.watcher")

// commonWatcher implements common watcher logic in one place to
// reduce code duplication, but it's not in fact a complete watcher;
// it's intended for embedding.
Expand Down Expand Up @@ -63,7 +65,7 @@ func (w *commonWatcher) commonLoop() {
defer w.wg.Done()
<-w.tomb.Dying()
if err := w.call("Stop", nil); err != nil {
log.Errorf("state/api: error trying to stop watcher: %v", err)
logger.Errorf("error trying to stop watcher: %v", err)
}
}()
w.wg.Add(1)
Expand Down
9 changes: 4 additions & 5 deletions store/lpad.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"launchpad.net/lpad"

"launchpad.net/juju-core/charm"
"launchpad.net/juju-core/log"
)

type PublishBranchError struct {
Expand Down Expand Up @@ -55,13 +54,13 @@ func PublishCharmsDistro(store *Store, apiBase lpad.APIBase) error {
burl, curl, err := uniqueNameURLs(tip.UniqueName)
if err != nil {
errs = append(errs, PublishBranchError{tip.UniqueName, err})
log.Errorf("%v\n", err)
logger.Errorf("%v", err)
continue
}
log.Infof("----- %s\n", burl)
logger.Infof("%s\n", burl)
if tip.Revision == "" {
errs = append(errs, PublishBranchError{burl, fmt.Errorf("branch has no revisions")})
log.Errorf("branch has no revisions\n")
logger.Errorf("branch has no revisions\n")
continue
}
// Charm is published in the personal URL and in any explicitly
Expand All @@ -84,7 +83,7 @@ func PublishCharmsDistro(store *Store, apiBase lpad.APIBase) error {
}
if err != nil {
errs = append(errs, PublishBranchError{burl, err})
log.Errorf("%v\n", err)
logger.Errorf("%v", err)
}
}
if errs != nil {
Expand Down
13 changes: 6 additions & 7 deletions store/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"time"

"launchpad.net/juju-core/charm"
"launchpad.net/juju-core/log"
)

const DefaultSeries = "precise"
Expand Down Expand Up @@ -132,7 +131,7 @@ func (s *Server) serveInfo(w http.ResponseWriter, r *http.Request) {
_, err = w.Write(data)
}
if err != nil {
log.Errorf("store: cannot write content: %v", err)
logger.Errorf("cannot write content: %v", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
Expand Down Expand Up @@ -180,7 +179,7 @@ func (s *Server) serveEvent(w http.ResponseWriter, r *http.Request) {
_, err = w.Write(data)
}
if err != nil {
log.Errorf("store: cannot write content: %v", err)
logger.Errorf("cannot write content: %v", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
Expand All @@ -202,7 +201,7 @@ func (s *Server) serveCharm(w http.ResponseWriter, r *http.Request) {
}
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
log.Errorf("store: cannot open charm %q: %v", curl, err)
logger.Errorf("cannot open charm %q: %v", curl, err)
return
}
if statsEnabled(r) {
Expand All @@ -214,7 +213,7 @@ func (s *Server) serveCharm(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Length", strconv.FormatInt(info.BundleSize(), 10))
_, err = io.Copy(w, rc)
if err != nil {
log.Errorf("store: failed to stream charm %q: %v", curl, err)
logger.Errorf("failed to stream charm %q: %v", curl, err)
}
}

Expand Down Expand Up @@ -303,7 +302,7 @@ func (s *Server) serveStats(w http.ResponseWriter, r *http.Request) {

entries, err := s.store.Counters(&req)
if err != nil {
log.Errorf("store: cannot query counters: %v", err)
logger.Errorf("cannot query counters: %v", err)
w.WriteHeader(http.StatusInternalServerError)
return
}
Expand Down Expand Up @@ -332,7 +331,7 @@ func (s *Server) serveStats(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Length", strconv.Itoa(len(buf)))
_, err = w.Write(buf)
if err != nil {
log.Errorf("store: cannot write content: %v", err)
logger.Errorf("cannot write content: %v", err)
w.WriteHeader(http.StatusInternalServerError)
}
}
Expand Down
Loading

0 comments on commit c77cfec

Please sign in to comment.