本文整理汇总了Golang中launchpad/net/loggo.GetLogger函数的典型用法代码示例。如果您正苦于以下问题:Golang GetLogger函数的具体用法?Golang GetLogger怎么用?Golang GetLogger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetLogger函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SetUpTest
func (s *baseProviderSuite) SetUpTest(c *gc.C) {
s.LoggingSuite.SetUpTest(c)
s.TestSuite.SetUpTest(c)
s.home = testing.MakeFakeHomeNoEnvironments(c, "test")
loggo.GetLogger("juju.environs.local").SetLogLevel(loggo.TRACE)
s.restore = local.MockAddressForInterface()
}
示例2: Start
// Start starts logging using the given Context.
func (l *Log) Start(ctx *Context) (err error) {
var target io.Writer
if l.Path != "" {
path := ctx.AbsPath(l.Path)
target, err = os.OpenFile(path, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
if err != nil {
return err
}
} else if l.Verbose || l.Debug {
target = ctx.Stderr
}
if target != nil {
writer := loggo.NewSimpleWriter(target, &loggo.DefaultFormatter{})
_, err = loggo.ReplaceDefaultWriter(writer)
if err != nil {
return err
}
} else {
loggo.RemoveWriter("default")
}
if l.Verbose || l.Debug {
level := loggo.INFO
if l.Debug {
level = loggo.DEBUG
}
// Set the level on the root logger.
loggo.GetLogger("").SetLogLevel(level)
}
loggo.ConfigureLoggers(l.Config)
return nil
}
示例3: TestVerboseSetsLogLevel
func (s *LogSuite) TestVerboseSetsLogLevel(c *C) {
l := &cmd.Log{Verbose: true}
ctx := testing.Context(c)
err := l.Start(ctx)
c.Assert(err, IsNil)
c.Assert(loggo.GetLogger("").LogLevel(), Equals, loggo.INFO)
}
示例4: TestDebugSetsLogLevel
func (s *LogSuite) TestDebugSetsLogLevel(c *C) {
l := &cmd.Log{Debug: true}
ctx := testing.Context(c)
err := l.Start(ctx)
c.Assert(err, IsNil)
c.Assert(loggo.GetLogger("").LogLevel(), Equals, loggo.DEBUG)
}
示例5: SetUpTest
func (s *suite) SetUpTest(c *C) {
var err error
s.writer = &testWriter{}
s.oldWriter, s.oldLevel, err = loggo.RemoveWriter("default")
c.Assert(err, IsNil)
err = loggo.RegisterWriter("test", s.writer, loggo.TRACE)
c.Assert(err, IsNil)
logger := loggo.GetLogger("juju")
logger.SetLogLevel(loggo.TRACE)
}
示例6: serveConn
func (srv *Server) serveConn(wsConn *websocket.Conn) error {
codec := jsoncodec.NewWebsocket(wsConn)
if loggo.GetLogger("").EffectiveLogLevel() >= loggo.DEBUG {
codec.SetLogging(true)
}
conn := rpc.NewConn(codec)
if err := conn.Serve(newStateServer(srv, conn), serverError); err != nil {
return err
}
conn.Start()
select {
case <-conn.Dead():
case <-srv.tomb.Dying():
}
return conn.Close()
}
示例7: NewMinUnitsWorker
// Copyright 2012, 2013 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package minunitsworker
import (
"launchpad.net/loggo"
"launchpad.net/juju-core/state"
"launchpad.net/juju-core/state/api"
"launchpad.net/juju-core/worker"
)
var logger = loggo.GetLogger("juju.worker.minunitsworker")
// MinUnitsWorker ensures the minimum number of units for services is respected.
type MinUnitsWorker struct {
st *state.State
}
// NewMinUnitsWorker returns a Worker that runs service.EnsureMinUnits()
// if the number of alive units belonging to a service decreases, or if the
// minimum required number of units for a service is increased.
func NewMinUnitsWorker(st *state.State) worker.Worker {
mu := &MinUnitsWorker{st: st}
return worker.NewStringsWorker(mu)
}
func (mu *MinUnitsWorker) SetUp() (api.StringsWatcher, error) {
return mu.st.WatchMinUnits(), nil
}
示例8:
package environs
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"launchpad.net/goyaml"
"launchpad.net/loggo"
"launchpad.net/juju-core/environs/config"
)
var logger = loggo.GetLogger("juju.environs")
// environ holds information about one environment.
type environ struct {
config *config.Config
err error // an error if the config data could not be parsed.
}
// Environs holds information about each named environment
// in an environments.yaml file.
type Environs struct {
Default string // The name of the default environment.
environs map[string]environ
}
// Names returns the list of environment names.
示例9: ChangeAgentTools
return "must restart: an agent upgrade is available"
}
// ChangeAgentTools does the actual agent upgrade.
// It should be called just before an agent exits, so that
// it will restart running the new tools.
func (e *UpgradeReadyError) ChangeAgentTools() error {
tools, err := tools.ChangeAgentTools(e.DataDir, e.AgentName, e.NewTools.Version)
if err != nil {
return err
}
logger.Infof("upgraded from %v to %v (%q)", e.OldTools.Version, tools.Version, tools.URL)
return nil
}
var logger = loggo.GetLogger("juju.worker.upgrader")
// Upgrader represents a worker that watches the state for upgrade
// requests.
type Upgrader struct {
tomb tomb.Tomb
st *upgrader.State
dataDir string
tag string
}
// New returns a new upgrader worker. It watches changes to the
// current version of the current agent (with the given tag)
// and tries to download the tools for any new version
// into the given data directory.
// If an upgrade is needed, the worker will exit with an
示例10: Errorf
// Copyright 2011, 2012, 2013 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package log
import (
"launchpad.net/loggo"
)
var (
logger = loggo.GetLogger("juju")
)
// Errorf logs a message using the ERROR priority.
func Errorf(format string, a ...interface{}) error {
logger.Logf(loggo.ERROR, format, a...)
return nil
}
// Warningf logs a message using the WARNING priority.
func Warningf(format string, a ...interface{}) error {
logger.Logf(loggo.WARNING, format, a...)
return nil
}
// Noticef logs a message using the NOTICE priority.
// Notice doesn't really convert to the loggo priorities...
func Noticef(format string, a ...interface{}) error {
logger.Logf(loggo.INFO, format, a...)
return nil
}
示例11: Info
import (
"fmt"
"launchpad.net/gnuflag"
"launchpad.net/loggo"
"launchpad.net/tomb"
"launchpad.net/juju-core/cmd"
"launchpad.net/juju-core/names"
"launchpad.net/juju-core/state"
"launchpad.net/juju-core/worker"
"launchpad.net/juju-core/worker/uniter"
"launchpad.net/juju-core/worker/upgrader"
)
var agentLogger = loggo.GetLogger("juju.jujud")
// UnitAgent is a cmd.Command responsible for running a unit agent.
type UnitAgent struct {
cmd.CommandBase
tomb tomb.Tomb
Conf AgentConf
UnitName string
runner *worker.Runner
}
// Info returns usage information for the command.
func (a *UnitAgent) Info() *cmd.Info {
return &cmd.Info{
Name: "unit",
Purpose: "run a juju unit agent",
示例12:
// Licensed under the AGPLv3, see LICENCE file for details.
package deployer
import (
"fmt"
"launchpad.net/juju-core/errors"
"launchpad.net/juju-core/state"
"launchpad.net/juju-core/state/watcher"
"launchpad.net/juju-core/utils"
"launchpad.net/juju-core/utils/set"
"launchpad.net/loggo"
"launchpad.net/tomb"
)
var logger = loggo.GetLogger("juju.deployer")
// Deployer is responsible for deploying and recalling unit agents, according
// to changes in a set of state units; and for the final removal of its agents'
// units from state when they are no longer needed.
type Deployer struct {
tomb tomb.Tomb
st *state.State
ctx Context
machineId string
deployed set.Strings
}
// Context abstracts away the differences between different unit deployment
// strategies; where a Deployer is responsible for what to deploy, a Context
// is responsible for how to deploy.
示例13:
package beacon
import (
"fmt"
"launchpad.net/loggo"
"os"
"os/exec"
"os/signal"
)
var log = loggo.GetLogger("hivy")
const (
superVerboseLogLevel loggo.Level = loggo.TRACE
verboseLogLevel loggo.Level = loggo.INFO
defaultLogLevel loggo.Level = loggo.WARNING
// Change here to absolute or relative path if etcd is not in your $PATH
etcdBin string = "etcd"
// Allowed is a macro representing an accessible method
Allowed string = "true"
// Forbidden is a macro representing an hiden method
Forbidden string = "false"
)
// Version follows unstable git tag
type Version struct {
major int
minor int
fix int
}
示例14: main
"time"
"launchpad.net/loggo"
"launchpad.net/juju-core/charm"
"launchpad.net/juju-core/environs"
"launchpad.net/juju-core/juju"
"launchpad.net/juju-core/state/api/params"
)
// Import the providers.
import (
_ "launchpad.net/juju-core/environs/all"
)
var logger = loggo.GetLogger("juju.builddb")
func main() {
if err := build(); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
}
func build() error {
environ, err := environs.NewFromName("")
if err != nil {
return err
}
conn, err := juju.NewConn(environ)
if err != nil {
示例15: NewLxcBroker
// Licensed under the AGPLv3, see LICENCE file for details.
package provisioner
import (
"launchpad.net/loggo"
"launchpad.net/juju-core/constraints"
"launchpad.net/juju-core/container/lxc"
"launchpad.net/juju-core/environs/config"
"launchpad.net/juju-core/instance"
"launchpad.net/juju-core/state"
"launchpad.net/juju-core/state/api"
)
var lxcLogger = loggo.GetLogger("juju.provisioner.lxc")
var _ Broker = (*lxcBroker)(nil)
func NewLxcBroker(config *config.Config, tools *state.Tools) Broker {
return &lxcBroker{
manager: lxc.NewContainerManager(lxc.ManagerConfig{Name: "juju"}),
config: config,
tools: tools,
}
}
type lxcBroker struct {
manager lxc.ContainerManager
config *config.Config
tools *state.Tools