本文整理汇总了Golang中github.com/cloudfoundry/bosh-utils/logger.NewLogger函数的典型用法代码示例。如果您正苦于以下问题:Golang NewLogger函数的具体用法?Golang NewLogger怎么用?Golang NewLogger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewLogger函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: newSignalableFileLogger
func newSignalableFileLogger(logPath string, level boshlog.LogLevel) boshlog.Logger {
// Log file logger errors to the STDERR logger
logger := boshlog.NewLogger(boshlog.LevelError)
fileSystem := boshsys.NewOsFileSystem(logger)
// log file will be closed by process exit
// log file readable by all
logfileLogger, _, err := boshlogfile.New(level, logPath, boshlogfile.DefaultLogFileMode, fileSystem)
if err != nil {
logger := boshlog.NewLogger(boshlog.LevelError)
ui := biui.NewConsoleUI(logger)
fail(err, ui, logger, nil)
}
return newSignalableLogger(logfileLogger)
}
示例2: buildFactory
func buildFactory() (factory Factory) {
config := davconf.Config{User: "some user"}
logger := boshlog.NewLogger(boshlog.LevelNone)
factory = NewFactory(logger)
factory.SetConfig(config)
return
}
示例3: main
func main() {
var cfg *config.Config
if configFile != "" {
log.Printf("Loading file: %s\n", configFile)
cfg = config.InitConfigFromFile(configFile)
} else {
log.Fatal("Config file not specified.")
}
level, err := logger.Levelify(cfg.Logging.Level)
if err != nil {
panic(err.Error())
}
logger := logger.NewLogger(level)
dnsUpdater := dns.NewDnsUpdater(*cfg, logger)
go dnsUpdater.Run()
// error chan not being used by anything, just to prevent main from exiting
errCh := make(chan error, 1)
select {
case <-errCh:
return
}
}
示例4: buildSSHAction
func buildSSHAction(settingsService boshsettings.Service) (*fakeplatform.FakePlatform, SSHAction) {
platform := fakeplatform.NewFakePlatform()
dirProvider := boshdirs.NewProvider("/foo")
logger := boshlog.NewLogger(boshlog.LevelNone)
action := NewSSH(settingsService, platform, dirProvider, logger)
return platform, action
}
示例5: NewTestEnvironment
func NewTestEnvironment(
cmdRunner boshsys.CmdRunner,
) *TestEnvironment {
return &TestEnvironment{
cmdRunner: cmdRunner,
currentDeviceNum: 2,
logger: logger.NewLogger(logger.LevelDebug),
}
}
示例6: runGet
func runGet(config davconf.Config, args []string) error {
logger := boshlog.NewLogger(boshlog.LevelNone)
factory := NewFactory(logger)
factory.SetConfig(config)
cmd, err := factory.Create("get")
Expect(err).ToNot(HaveOccurred())
return cmd.Run(args)
}
示例7: newLogger
func newLogger() boshlog.Logger {
logLevelString := os.Getenv("BOSH_INIT_LOG_LEVEL")
level := boshlog.LevelNone
if logLevelString != "" {
var err error
level, err = boshlog.Levelify(logLevelString)
if err != nil {
err = bosherr.WrapError(err, "Invalid BOSH_INIT_LOG_LEVEL value")
logger := boshlog.NewLogger(boshlog.LevelError)
ui := biui.NewConsoleUI(logger)
fail(err, ui, logger, nil)
}
}
logPath := os.Getenv("BOSH_INIT_LOG_PATH")
if logPath != "" {
return newSignalableFileLogger(logPath, level)
}
return newSignalableLogger(boshlog.NewLogger(level))
}
示例8: newFakeClient
func newFakeClient(shortClient, longClient *fakehttp.FakeClient) Client {
logger := boshlog.NewLogger(boshlog.LevelNone)
return NewHTTPClient(
"agent.example.com",
"fake-user",
"fake-pass",
shortClient,
longClient,
logger,
)
}
示例9: newRealClient
func newRealClient(url string) Client {
logger := boshlog.NewLogger(boshlog.LevelNone)
return NewHTTPClient(
url,
"fake-user",
"fake-pass",
http.DefaultClient,
http.DefaultClient,
logger,
)
}
示例10: describeDummyPlatform
func describeDummyPlatform() {
var (
platform Platform
collector boshstats.Collector
fs boshsys.FileSystem
cmdRunner boshsys.CmdRunner
dirProvider boshdirs.Provider
devicePathResolver boshdpresolv.DevicePathResolver
logger boshlog.Logger
)
BeforeEach(func() {
collector = &fakestats.FakeCollector{}
fs = fakesys.NewFakeFileSystem()
cmdRunner = fakesys.NewFakeCmdRunner()
dirProvider = boshdirs.NewProvider("/fake-dir")
devicePathResolver = fakedpresolv.NewFakeDevicePathResolver()
logger = boshlog.NewLogger(boshlog.LevelNone)
})
JustBeforeEach(func() {
platform = NewDummyPlatform(
collector,
fs,
cmdRunner,
dirProvider,
devicePathResolver,
logger,
)
})
Describe("GetDefaultNetwork", func() {
It("returns the contents of dummy-defaults-network-settings.json since that's what the dummy cpi writes", func() {
settingsFilePath := "/fake-dir/bosh/dummy-default-network-settings.json"
fs.WriteFileString(settingsFilePath, `{"IP": "1.2.3.4"}`)
network, err := platform.GetDefaultNetwork()
Expect(err).NotTo(HaveOccurred())
Expect(network.IP).To(Equal("1.2.3.4"))
})
})
Describe("GetCertManager", func() {
It("returs a dummy cert manager", func() {
certManager := platform.GetCertManager()
Expect(certManager.UpdateCertificates("")).Should(BeNil())
})
})
}
示例11: init
func init() {
Describe("Stop", func() {
var (
jobSupervisor *fakejobsuper.FakeJobSupervisor
platform *fakeplatform.FakePlatform
settingsService *fakesettings.FakeSettingsService
logger boshlog.Logger
specService *fakeas.FakeV1Service
dualDCSupport *nimbus.DualDCSupport
action StopAction
)
BeforeEach(func() {
jobSupervisor = fakejobsuper.NewFakeJobSupervisor()
platform = fakeplatform.NewFakePlatform()
logger = boshlog.NewLogger(boshlog.LevelNone)
specService = fakeas.NewFakeV1Service()
settingsService = &fakesettings.FakeSettingsService{}
dualDCSupport = nimbus.NewDualDCSupport(
platform.GetRunner(),
platform.GetFs(),
platform.GetDirProvider(),
specService,
settingsService,
logger,
)
action = NewStop(jobSupervisor, dualDCSupport, platform)
})
It("is asynchronous", func() {
Expect(action.IsAsynchronous()).To(BeTrue())
})
It("is not persistent", func() {
Expect(action.IsPersistent()).To(BeFalse())
})
It("returns stopped", func() {
stopped, err := action.Run()
Expect(err).ToNot(HaveOccurred())
Expect(stopped).To(Equal("stopped"))
})
It("stops job supervisor services", func() {
_, err := action.Run()
Expect(err).ToNot(HaveOccurred())
Expect(jobSupervisor.Stopped).To(BeTrue())
})
})
}
示例12: main
func main() {
logger := boshlog.NewLogger(boshlog.LevelNone)
cmdFactory := cmd.NewFactory(logger)
cmdRunner := cmd.NewRunner(cmdFactory)
cli := app.New(cmdRunner)
err := cli.Run(os.Args)
if err != nil {
fmt.Printf("Error running app - %s", err.Error())
os.Exit(1)
}
}
示例13: TestIntegration
func TestIntegration(t *testing.T) {
RegisterFailHandler(Fail)
BeforeSuite(func() {
logger := boshlog.NewLogger(boshlog.LevelDebug)
cmdRunner := boshsys.NewExecCmdRunner(logger)
testEnvironment = NewTestEnvironment(cmdRunner)
// Required for reverse-compatibility with older bosh-lite
// (remove once a new warden stemcell is built).
err := testEnvironment.ConfigureAgentForGenericInfrastructure()
Expect(err).ToNot(HaveOccurred())
})
RunSpecs(t, "Integration Suite")
}
示例14: Create
//TODO: rename NewBlobstore
func (f blobstoreFactory) Create(blobstoreURL string, httpClient *http.Client) (Blobstore, error) {
logger := boshlog.NewLogger(boshlog.LevelNone)
blobstoreConfig, err := f.parseBlobstoreURL(blobstoreURL)
if err != nil {
return nil, bosherr.WrapError(err, "Creating blobstore config")
}
davClient := boshdavcli.NewClient(boshdavcliconf.Config{
Endpoint: fmt.Sprintf("%s/blobs", blobstoreConfig.Endpoint),
User: blobstoreConfig.Username,
Password: blobstoreConfig.Password,
}, httpClient, logger)
return NewBlobstore(davClient, f.uuidGenerator, f.fs, f.logger), nil
}
示例15: init
func init() {
Describe("ListDisk", func() {
var (
settingsService *fakesettings.FakeSettingsService
platform *fakeplatform.FakePlatform
logger boshlog.Logger
action ListDiskAction
)
BeforeEach(func() {
settingsService = &fakesettings.FakeSettingsService{}
platform = fakeplatform.NewFakePlatform()
logger = boshlog.NewLogger(boshlog.LevelNone)
action = NewListDisk(settingsService, platform, logger)
})
It("list disk should be synchronous", func() {
Expect(action.IsAsynchronous()).To(BeFalse())
})
It("is not persistent", func() {
Expect(action.IsPersistent()).To(BeFalse())
})
It("list disk run", func() {
platform.MountedDevicePaths = []string{"/dev/sdb", "/dev/sdc"}
settingsService.Settings.Disks = boshsettings.Disks{
Persistent: map[string]interface{}{
"volume-1": "/dev/sda",
"volume-2": "/dev/sdb",
"volume-3": "/dev/sdc",
},
}
value, err := action.Run()
Expect(err).ToNot(HaveOccurred())
values, ok := value.([]string)
Expect(ok).To(BeTrue())
Expect(values).To(ContainElement("volume-2"))
Expect(values).To(ContainElement("volume-3"))
Expect(len(values)).To(Equal(2))
})
})
}