当前位置: 首页>>代码示例>>Golang>>正文


Golang logger.NewLogger函数代码示例

本文整理汇总了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)
}
开发者ID:mattcui,项目名称:bosh-init,代码行数:15,代码来源:main.go

示例2: buildFactory

func buildFactory() (factory Factory) {
	config := davconf.Config{User: "some user"}
	logger := boshlog.NewLogger(boshlog.LevelNone)
	factory = NewFactory(logger)
	factory.SetConfig(config)
	return
}
开发者ID:mattcui,项目名称:bosh-init,代码行数:7,代码来源:factory_test.go

示例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
	}
}
开发者ID:nimbus-cloud,项目名称:postgresql-boshrelease,代码行数:27,代码来源:main.go

示例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
}
开发者ID:vinodpanicker,项目名称:bosh-agent,代码行数:7,代码来源:ssh_test.go

示例5: NewTestEnvironment

func NewTestEnvironment(
	cmdRunner boshsys.CmdRunner,
) *TestEnvironment {
	return &TestEnvironment{
		cmdRunner:        cmdRunner,
		currentDeviceNum: 2,
		logger:           logger.NewLogger(logger.LevelDebug),
	}
}
开发者ID:EMC-CMD,项目名称:bosh-agent,代码行数:9,代码来源:test_environment.go

示例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)
}
开发者ID:mattcui,项目名称:bosh-init,代码行数:10,代码来源:get_test.go

示例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))
}
开发者ID:mattcui,项目名称:bosh-init,代码行数:21,代码来源:main.go

示例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,
	)
}
开发者ID:EMC-CMD,项目名称:bosh-agent,代码行数:12,代码来源:http_client_test.go

示例9: newRealClient

func newRealClient(url string) Client {
	logger := boshlog.NewLogger(boshlog.LevelNone)

	return NewHTTPClient(
		url,
		"fake-user",
		"fake-pass",
		http.DefaultClient,
		http.DefaultClient,
		logger,
	)
}
开发者ID:EMC-CMD,项目名称:bosh-agent,代码行数:12,代码来源:http_client_test.go

示例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())
		})
	})
}
开发者ID:EMC-CMD,项目名称:bosh-agent,代码行数:51,代码来源:dummy_platform_test.go

示例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())
		})
	})
}
开发者ID:nimbus-cloud,项目名称:bosh-agent,代码行数:50,代码来源:stop_test.go

示例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)
	}
}
开发者ID:mattcui,项目名称:bosh-init,代码行数:14,代码来源:dav.go

示例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")
}
开发者ID:EMC-CMD,项目名称:bosh-agent,代码行数:16,代码来源:integration_suite_test.go

示例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
}
开发者ID:mattcui,项目名称:bosh-init,代码行数:18,代码来源:blobstore_factory.go

示例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))
		})
	})
}
开发者ID:EMC-CMD,项目名称:bosh-agent,代码行数:45,代码来源:list_disk_test.go


注:本文中的github.com/cloudfoundry/bosh-utils/logger.NewLogger函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。