• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang util.RootLogger函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/wercker/wercker/util.RootLogger函数的典型用法代码示例。如果您正苦于以下问题:Golang RootLogger函数的具体用法?Golang RootLogger怎么用?Golang RootLogger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了RootLogger函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: Exit

// Exit with either an error or a panic
func (s *SoftExit) Exit(v ...interface{}) error {
	if s.options.Debug {
		// Clearly this will cause it's own exit if it gets called.
		util.RootLogger().Panicln(v...)
	}
	util.RootLogger().Errorln(v...)
	return fmt.Errorf("Exiting.")
}
开发者ID:rlugojr,项目名称:wercker,代码行数:9,代码来源:main.go


示例2: getServerVersion

func getServerVersion(channel string) (*util.Versions, error) {
	logger := util.RootLogger().WithField("Logger", "getServerVersion")

	url := fmt.Sprintf("https://s3.amazonaws.com/downloads.wercker.com/cli/%s/version.json", channel)

	nv := &util.Versions{}
	client := &http.Client{}

	req, err := http.NewRequest("GET", url, nil)
	if err != nil {
		logger.WithField("Error", err).Debug("Unable to create request to version endpoint")
		return nil, err
	}

	res, err := client.Do(req)
	if err != nil {
		logger.WithField("Error", err).Debug("Unable to execute HTTP request to version endpoint")
		return nil, err
	}

	body, err := ioutil.ReadAll(res.Body)
	if err != nil {
		logger.WithField("Error", err).Debug("Unable to read response body")
		return nil, err
	}

	err = json.Unmarshal(body, nv)
	if err != nil {
		logger.WithField("Error", err).Debug("Unable to unmarshal versions")
		return nil, err
	}
	return nv, nil
}
开发者ID:wercker,项目名称:wercker,代码行数:33,代码来源:update.go


示例3: getYml

// TODO(mies): maybe move to util.go at some point
func getYml(detected string, options *core.DetectOptions) {
	logger := util.RootLogger().WithField("Logger", "Main")

	yml := "wercker.yml"
	if _, err := os.Stat(yml); err == nil {
		logger.Println(yml, "already exists. Do you want to overwrite? (yes/no)")
		if !askForConfirmation() {
			logger.Println("Exiting...")
			os.Exit(1)
		}
	}
	url := fmt.Sprintf("%s/api/v2/yml/%s", options.BaseURL, detected)
	res, err := http.Get(url)
	if err != nil {
		logger.WithField("Error", err).Error("Unable to reach wercker API")
		os.Exit(1)
	}
	defer res.Body.Close()

	body, err := ioutil.ReadAll(res.Body)
	if err != nil {
		logger.WithField("Error", err).Error("Unable to read response")
	}

	err = ioutil.WriteFile("wercker.yml", body, 0644)
	if err != nil {
		logger.WithField("Error", err).Error("Unable to write wercker.yml file")
	}

}
开发者ID:rlugojr,项目名称:wercker,代码行数:31,代码来源:main.go


示例4: NewStep

func NewStep(config *core.StepConfig, options *core.PipelineOptions, dockerOptions *DockerOptions) (core.Step, error) {
	// NOTE(termie) Special case steps are special
	if config.ID == "internal/docker-push" {
		return NewDockerPushStep(config, options, dockerOptions)
	}
	if config.ID == "internal/docker-scratch-push" {
		return NewDockerScratchPushStep(config, options, dockerOptions)
	}
	if config.ID == "internal/store-container" {
		return NewStoreContainerStep(config, options, dockerOptions)
	}
	if strings.HasPrefix(config.ID, "internal/") {
		if !options.EnableDevSteps {
			util.RootLogger().Warnln("Ignoring dev step:", config.ID)
			return nil, nil
		}
	}
	if options.EnableDevSteps {
		if config.ID == "internal/watch" {
			return NewWatchStep(config, options, dockerOptions)
		}
		if config.ID == "internal/shell" {
			return NewShellStep(config, options, dockerOptions)
		}
	}
	return NewDockerStep(config, options, dockerOptions)
}
开发者ID:rlugojr,项目名称:wercker,代码行数:27,代码来源:step.go


示例5: DumpOptions

// DumpOptions prints out a sorted list of options
func DumpOptions(options interface{}, indent ...string) {
	indent = append(indent, "  ")
	s := reflect.ValueOf(options).Elem()
	typeOfT := s.Type()
	names := []string{}
	for i := 0; i < s.NumField(); i++ {
		// f := s.Field(i)
		fieldName := typeOfT.Field(i).Name
		if fieldName != "HostEnv" {
			names = append(names, fieldName)
		}
	}
	sort.Strings(names)
	logger := util.RootLogger().WithField("Logger", "Options")

	for _, name := range names {
		r := reflect.ValueOf(options)
		f := reflect.Indirect(r).FieldByName(name)
		if strings.HasSuffix(name, "Options") {
			if len(indent) > 1 && name == "GlobalOptions" {
				continue
			}
			logger.Debugln(fmt.Sprintf("%s%s %s", strings.Join(indent, ""), name, f.Type()))
			DumpOptions(f.Interface(), indent...)
		} else {
			logger.Debugln(fmt.Sprintf("%s%s %s = %v", strings.Join(indent, ""), name, f.Type(), f.Interface()))
		}
	}
}
开发者ID:rlugojr,项目名称:wercker,代码行数:30,代码来源:main.go


示例6: NewDeployOptions

// NewDeployOptions constructor
func NewDeployOptions(c util.Settings, e *util.Environment) (*PipelineOptions, error) {
	pipelineOpts, err := NewPipelineOptions(c, e)
	if err != nil {
		return nil, err
	}
	// default to last build output if none defined
	target, _ := c.String("target")
	if target == "" {
		found, err := util.Exists("./.wercker/latest/output")
		if err == nil && found {
			util.RootLogger().Println("No target specified, using recent build output.")
			pipelineOpts.ProjectPath, _ = filepath.Abs("./.wercker/latest/output")
		}
	}

	// if the deploy target path does not have a wercker.yml, use the current one
	werckerYml, _ := c.String("wercker-yml")
	if werckerYml == "" {
		found, _ := util.Exists(filepath.Join(pipelineOpts.ProjectPath, "wercker.yml"))
		if !found {
			pipelineOpts.WerckerYml = "./wercker.yml"
		}
	}

	if pipelineOpts.RunID == "" {
		pipelineOpts.RunID = uuid.NewRandom().String()
	}
	return pipelineOpts, nil
}
开发者ID:wercker,项目名称:wercker,代码行数:30,代码来源:options.go


示例7: normalizeRegistry

func normalizeRegistry(address string) string {
	logger := util.RootLogger().WithField("Logger", "Docker")
	if address == "" {
		logger.Debugln("No registry address provided, using https://registry.hub.docker.com")
		return "https://registry.hub.docker.com/v1/"
	}
	parsed, err := url.Parse(address)
	if err != nil {
		logger.Errorln("Registry address is invalid, this will probably fail:", address)
		return address
	}
	if parsed.Scheme != "https" {
		logger.Warnln("Registry address is expected to begin with 'https://', forcing it to use https")
		parsed.Scheme = "https"
		address = parsed.String()
	}
	if strings.HasSuffix(address, "/") {
		address = address[:len(address)-1]
	}

	parts := strings.Split(address, "/")
	possiblyAPIVersionStr := parts[len(parts)-1]

	// we only support v1, so...
	if possiblyAPIVersionStr == "v2" {
		logger.Warnln("Registry API v2 not supported, using v1")
		newParts := append(parts[:len(parts)-1], "v1")
		address = strings.Join(newParts, "/")
	} else if possiblyAPIVersionStr != "v1" {
		newParts := append(parts, "v1")
		address = strings.Join(newParts, "/")
	}
	return address + "/"
}
开发者ID:rlugojr,项目名称:wercker,代码行数:34,代码来源:docker.go


示例8: NewDockerPushStep

// NewDockerPushStep is a special step for doing docker pushes
func NewDockerPushStep(stepConfig *core.StepConfig, options *core.PipelineOptions, dockerOptions *DockerOptions) (*DockerPushStep, error) {
	name := "docker-push"
	displayName := "docker push"
	if stepConfig.Name != "" {
		displayName = stepConfig.Name
	}

	// Add a random number to the name to prevent collisions on disk
	stepSafeID := fmt.Sprintf("%s-%s", name, uuid.NewRandom().String())

	baseStep := core.NewBaseStep(core.BaseStepOptions{
		DisplayName: displayName,
		Env:         &util.Environment{},
		ID:          name,
		Name:        name,
		Owner:       "wercker",
		SafeID:      stepSafeID,
		Version:     util.Version(),
	})

	return &DockerPushStep{
		BaseStep:      baseStep,
		data:          stepConfig.Data,
		logger:        util.RootLogger().WithField("Logger", "DockerPushStep"),
		options:       options,
		dockerOptions: dockerOptions,
	}, nil
}
开发者ID:rlugojr,项目名称:wercker,代码行数:29,代码来源:docker.go


示例9: NewDockerClient

// NewDockerClient based on options and env
func NewDockerClient(options *DockerOptions) (*DockerClient, error) {
	dockerHost := options.DockerHost
	tlsVerify := options.DockerTLSVerify

	logger := util.RootLogger().WithField("Logger", "Docker")

	var (
		client *docker.Client
		err    error
	)

	if tlsVerify == "1" {
		// We're using TLS, let's locate our certs and such
		// boot2docker puts its certs at...
		dockerCertPath := options.DockerCertPath

		// TODO(termie): maybe fast-fail if these don't exist?
		cert := path.Join(dockerCertPath, fmt.Sprintf("cert.pem"))
		ca := path.Join(dockerCertPath, fmt.Sprintf("ca.pem"))
		key := path.Join(dockerCertPath, fmt.Sprintf("key.pem"))
		client, err = docker.NewVersionnedTLSClient(dockerHost, cert, key, ca, "")
		if err != nil {
			return nil, err
		}
	} else {
		client, err = docker.NewClient(dockerHost)
		if err != nil {
			return nil, err
		}
	}
	return &DockerClient{Client: client, logger: logger}, nil
}
开发者ID:rlugojr,项目名称:wercker,代码行数:33,代码来源:docker.go


示例10: NewDockerFileCollector

// NewDockerFileCollector constructor
func NewDockerFileCollector(client *DockerClient, containerID string) *DockerFileCollector {
	return &DockerFileCollector{
		client:      client,
		containerID: containerID,
		logger:      util.RootLogger().WithField("Logger", "DockerFileCollector"),
	}
}
开发者ID:hughker,项目名称:wercker,代码行数:8,代码来源:artifact.go


示例11: NewDockerBox

// NewDockerBox from a name and other references
func NewDockerBox(boxConfig *core.BoxConfig, options *core.PipelineOptions, dockerOptions *DockerOptions) (*DockerBox, error) {
	name := boxConfig.ID

	if strings.Contains(name, "@") {
		return nil, fmt.Errorf("Invalid box name, '@' is not allowed in docker repositories.")
	}

	parts := strings.Split(name, ":")
	repository := parts[0]
	tag := "latest"
	if len(parts) > 1 {
		tag = parts[1]
	}
	if boxConfig.Tag != "" {
		tag = boxConfig.Tag
	}
	name = fmt.Sprintf("%s:%s", repository, tag)

	repoParts := strings.Split(repository, "/")
	shortName := repository
	if len(repoParts) > 1 {
		shortName = repoParts[len(repoParts)-1]
	}

	networkDisabled := false

	cmd := boxConfig.Cmd
	if cmd == "" {
		cmd = "/bin/bash"
	}

	entrypoint := boxConfig.Entrypoint

	logger := util.RootLogger().WithFields(util.LogFields{
		"Logger":    "Box",
		"Name":      name,
		"ShortName": shortName,
	})

	client, err := NewDockerClient(dockerOptions)
	if err != nil {
		return nil, err
	}
	return &DockerBox{
		Name:            name,
		ShortName:       shortName,
		client:          client,
		config:          boxConfig,
		options:         options,
		dockerOptions:   dockerOptions,
		repository:      repository,
		tag:             tag,
		networkDisabled: networkDisabled,
		logger:          logger,
		cmd:             cmd,
		entrypoint:      entrypoint,
		volumes:         []string{},
	}, nil
}
开发者ID:umcodemonkey,项目名称:wercker,代码行数:60,代码来源:box.go


示例12: NewDockerTransport

// NewDockerTransport constructor
func NewDockerTransport(options *core.PipelineOptions, dockerOptions *DockerOptions, containerID string) (core.Transport, error) {
	client, err := NewDockerClient(dockerOptions)
	if err != nil {
		return nil, err
	}
	logger := util.RootLogger().WithField("Logger", "DockerTransport")
	return &DockerTransport{options: options, client: client, containerID: containerID, logger: logger}, nil
}
开发者ID:wercker,项目名称:wercker,代码行数:9,代码来源:session.go


示例13: NewExternalServiceBox

// NewExternalServiceBox gives us an ExternalServiceBox from config
func NewExternalServiceBox(boxConfig *core.BoxConfig, options *core.PipelineOptions, dockerOptions *DockerOptions, builder Builder) (*ExternalServiceBox, error) {
	logger := util.RootLogger().WithField("Logger", "ExternalService")
	box := &DockerBox{options: options, dockerOptions: dockerOptions}
	return &ExternalServiceBox{
		InternalServiceBox: &InternalServiceBox{DockerBox: box, logger: logger},
		externalConfig:     boxConfig,
		builder:            builder,
	}, nil
}
开发者ID:hughker,项目名称:wercker,代码行数:10,代码来源:service.go


示例14: NewSession

// NewSession returns a new interactive session to a container.
func NewSession(options *PipelineOptions, transport Transport) *Session {
	logger := util.RootLogger().WithField("Logger", "Session")
	return &Session{
		options:    options,
		transport:  transport,
		logsHidden: false,
		logger:     logger,
	}
}
开发者ID:wercker,项目名称:wercker,代码行数:10,代码来源:session.go


示例15: AskForUpdate

// AskForUpdate asks users if they want to update and returns the answer
func AskForUpdate() bool {
	fmt.Println("Would you like update? [yN]")
	reader := bufio.NewReader(os.Stdin)
	line, err := reader.ReadString('\n')
	if err != nil {
		util.RootLogger().Errorln("Problem reading answer", err)
		return false
	}
	return strings.HasPrefix(strings.ToLower(line), "y")
}
开发者ID:wercker,项目名称:wercker,代码行数:11,代码来源:update.go


示例16: NewArtificer

// NewArtificer returns an Artificer
func NewArtificer(options *core.PipelineOptions, dockerOptions *DockerOptions) *Artificer {
	logger := util.RootLogger().WithField("Logger", "Artificer")

	s3store := core.NewS3Store(options.AWSOptions)

	return &Artificer{
		options: options,
		logger:  logger,
		store:   s3store,
	}
}
开发者ID:hughker,项目名称:wercker,代码行数:12,代码来源:artifact.go


示例17: NewAPIClient

// NewAPIClient returns our dumb client
func NewAPIClient(options *APIOptions) *APIClient {
	logger := util.RootLogger().WithFields(util.LogFields{
		"Logger": "API",
	})
	return &APIClient{
		baseURL: options.BaseURL,
		client:  &http.Client{},
		options: options,
		logger:  logger,
	}
}
开发者ID:wercker,项目名称:wercker,代码行数:12,代码来源:api.go


示例18: cmdLogout

func cmdLogout(options *core.LogoutOptions) error {
	soft := NewSoftExit(options.GlobalOptions)
	logger := util.RootLogger().WithField("Logger", "Main")

	logger.Println("Logging out")

	err := removeToken(options.GlobalOptions.AuthTokenStore)
	if err != nil {
		return soft.Exit(err)
	}
	return nil
}
开发者ID:rlugojr,项目名称:wercker,代码行数:12,代码来源:main.go


示例19: NewUpdater

// NewUpdater constructor
func NewUpdater(channel string) (*Updater, error) {
	serverVersion, err := getServerVersion(channel)
	if err != nil {
		return nil, err
	}
	return &Updater{
		CurrentVersion: util.GetVersions(),
		ServerVersion:  serverVersion,
		channel:        channel,
		l:              util.RootLogger().WithField("Logger", "Updater"),
	}, nil
}
开发者ID:wercker,项目名称:wercker,代码行数:13,代码来源:update.go


示例20: NewRunner

// NewRunner from global options
func NewRunner(ctx context.Context, options *core.PipelineOptions, dockerOptions *dockerlocal.DockerOptions, getPipeline pipelineGetter) (*Runner, error) {
	e, err := core.EmitterFromContext(ctx)
	if err != nil {
		return nil, err
	}
	logger := util.RootLogger().WithField("Logger", "Runner")
	// h, err := NewLogHandler()
	// if err != nil {
	//   p.logger.WithField("Error", err).Panic("Unable to LogHandler")
	// }
	// h.ListenTo(e)

	if options.Debug {
		dh := core.NewDebugHandler()
		dh.ListenTo(e)
	}

	l, err := event.NewLiteralLogHandler(options)
	if err != nil {
		logger.WithField("Error", err).Panic("Unable to event.LiteralLogHandler")
	}
	l.ListenTo(e)

	var mh *event.MetricsEventHandler
	if options.ShouldKeenMetrics {
		mh, err = event.NewMetricsHandler(options)
		if err != nil {
			logger.WithField("Error", err).Panic("Unable to MetricsHandler")
		}
		mh.ListenTo(e)
	}

	var r *event.ReportHandler
	if options.ShouldReport {
		r, err := event.NewReportHandler(options.ReporterHost, options.ReporterKey)
		if err != nil {
			logger.WithField("Error", err).Panic("Unable to event.ReportHandler")
		}
		r.ListenTo(e)
	}

	return &Runner{
		options:       options,
		dockerOptions: dockerOptions,
		literalLogger: l,
		metrics:       mh,
		reporter:      r,
		getPipeline:   getPipeline,
		logger:        logger,
		emitter:       e,
		formatter:     &util.Formatter{options.GlobalOptions.ShowColors},
	}, nil
}
开发者ID:sgoings,项目名称:wercker,代码行数:54,代码来源:runner.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang util.Environment类代码示例发布时间:2022-05-28
下一篇:
Golang util.NewTimer函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap