本文整理汇总了Golang中github.com/Sirupsen/logrus.Warningln函数的典型用法代码示例。如果您正苦于以下问题:Golang Warningln函数的具体用法?Golang Warningln怎么用?Golang Warningln使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Warningln函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: processUntracked
func (c *ArchiveCommand) processUntracked() {
if !c.Untracked {
return
}
var output bytes.Buffer
cmd := exec.Command("git", "ls-files", "-o")
cmd.Env = os.Environ()
cmd.Stdout = &output
cmd.Stderr = os.Stderr
logrus.Debugln("Executing command:", strings.Join(cmd.Args, " "))
err := cmd.Run()
if err == nil {
reader := bufio.NewReader(&output)
for {
line, _, err := reader.ReadLine()
if err == io.EOF {
break
} else if err != nil {
logrus.Warningln(err)
break
}
c.process(string(line))
}
} else {
logrus.Warningln(err)
}
}
开发者ID:mikew,项目名称:gitlab-ci-multi-runner,代码行数:28,代码来源:archive.go
示例2: createZipEntry
func createZipEntry(archive *zip.Writer, fileName string) error {
fi, err := os.Lstat(fileName)
if err != nil {
logrus.Warningln("File ignored:", err)
return nil
}
fh, err := zip.FileInfoHeader(fi)
if err != nil {
return err
}
fh.Name = fileName
fh.Extra = createZipExtra(fi)
switch fi.Mode() & os.ModeType {
case os.ModeDir:
return createZipDirectoryEntry(archive, fh)
case os.ModeSymlink:
return createZipSymlinkEntry(archive, fh)
case os.ModeNamedPipe, os.ModeSocket, os.ModeDevice:
// Ignore the files that of these types
logrus.Warningln("File ignored:", fileName)
return nil
default:
return createZipFileEntry(archive, fh)
}
}
开发者ID:bssthu,项目名称:gitlab-ci-multi-runner,代码行数:30,代码来源:zip_create.go
示例3: waitForInterrupts
func waitForInterrupts(finished *bool, abortSignal chan os.Signal, doneSignal chan int) {
signals := make(chan os.Signal)
signal.Notify(signals, os.Interrupt, syscall.SIGTERM, syscall.SIGQUIT)
interrupt := <-signals
if finished != nil {
*finished = true
}
// request stop, but wait for force exit
for interrupt == syscall.SIGQUIT {
log.Warningln("Requested quit, waiting for builds to finish")
interrupt = <-signals
}
log.Warningln("Requested exit:", interrupt)
go func() {
for {
abortSignal <- interrupt
}
}()
select {
case newSignal := <-signals:
log.Fatalln("forced exit:", newSignal)
case <-time.After(common.ShutdownTimeout * time.Second):
log.Fatalln("shutdown timedout")
case <-doneSignal:
}
}
开发者ID:bssthu,项目名称:gitlab-ci-multi-runner,代码行数:31,代码来源:single.go
示例4: UpdateBuild
func (n *GitLabClient) UpdateBuild(config RunnerConfig, id int, state BuildState, trace string) UpdateState {
request := UpdateBuildRequest{
Info: n.getRunnerVersion(config),
Token: config.Token,
State: state,
Trace: trace,
}
result, statusText := n.do(config.RunnerCredentials, "PUT", fmt.Sprintf("builds/%d.json", id), 200, &request, nil)
switch result {
case 200:
logrus.Println(config.ShortDescription(), id, "Submitting build to coordinator...", "ok")
return UpdateSucceeded
case 404:
logrus.Warningln(config.ShortDescription(), id, "Submitting build to coordinator...", "aborted")
return UpdateAbort
case 403:
logrus.Errorln(config.ShortDescription(), id, "Submitting build to coordinator...", "forbidden")
return UpdateAbort
case clientError:
logrus.Errorln(config.ShortDescription(), id, "Submitting build to coordinator...", "error", statusText)
return UpdateAbort
default:
logrus.Warningln(config.ShortDescription(), id, "Submitting build to coordinator...", "failed", statusText)
return UpdateFailed
}
}
开发者ID:mikew,项目名称:gitlab-ci-multi-runner,代码行数:27,代码来源:gitlab.go
示例5: installAptPackage
/*
Install a package with apt-get
*/
func (pkg *Package) installAptPackage(name string) error {
out, err := exec.Command("apt-get", "update").CombinedOutput()
if err != nil {
log.Warningln(string(out))
return err
}
out, err = exec.Command("apt-get", "install", "-y", name).CombinedOutput()
if err != nil {
log.Warningln(string(out))
return err
}
log.Println("Installed Apt package: ", string(out))
return nil
}
开发者ID:vektorlab,项目名称:otter,代码行数:17,代码来源:package.go
示例6: processPaths
func (c *fileArchiver) processPaths() {
for _, path := range c.Paths {
matches, err := filepath.Glob(path)
if err != nil {
logrus.Warningf("%s: %v", path, err)
continue
}
found := 0
for _, match := range matches {
err := filepath.Walk(match, func(path string, info os.FileInfo, err error) error {
if c.process(path) {
found++
}
return nil
})
if err != nil {
logrus.Warningln("Walking", match, err)
}
}
if found == 0 {
logrus.Warningf("%s: no matching files", path)
} else {
logrus.Infof("%s: found %d matching files", path, found)
}
}
}
开发者ID:bssthu,项目名称:gitlab-ci-multi-runner,代码行数:29,代码来源:file_archiver.go
示例7: dispatchCommand
func dispatchCommand(c *cli.Context, client *etcd.Client, cmd *command.Command) {
targets := c.StringSlice("target")
if targets == nil || len(targets) == 0 {
log.Warningln("no target set! try to send command to all registered host.")
targets = fetchHosts(c, client)
}
if targets == nil {
log.Fatalln("no target to send command.")
} else {
log.Infoln("send command to: ", targets)
}
for _, target := range targets {
key := fmt.Sprintf("/beacon/commands/single/%s/%s/",
target, cmd.Id)
if c.GlobalString("prefix") != "" {
key = fmt.Sprintf("/%s%s", strings.Trim(c.GlobalString("prefix"), "/"), key)
}
if _, err := client.Set(key, cmd.Marshal(), 0); err != nil {
log.WithFields(log.Fields{
"error": err.Error(),
}).Fatalln("send command failed.")
}
}
}
开发者ID:jmptrader,项目名称:beacon,代码行数:25,代码来源:utils.go
示例8: Execute
func (c *UnregisterCommand) Execute(context *cli.Context) {
if !common.DeleteRunner(c.URL, c.Token) {
log.Fatalln("Failed to delete runner")
}
err := c.loadConfig()
if err != nil {
log.Warningln(err)
return
}
runners := []*common.RunnerConfig{}
for _, otherRunner := range c.config.Runners {
if otherRunner.RunnerCredentials == c.RunnerCredentials {
continue
}
runners = append(runners, otherRunner)
}
// check if anything changed
if len(c.config.Runners) == len(runners) {
return
}
c.config.Runners = runners
// save config file
err = c.saveConfig()
if err != nil {
log.Fatalln("Failed to update", c.ConfigFile, err)
}
log.Println("Updated", c.ConfigFile)
}
开发者ID:zhangxq5012,项目名称:gitlab-ci-multi-runner,代码行数:33,代码来源:unregister.go
示例9: GetBuild
func (n *GitLabClient) GetBuild(config RunnerConfig) (*GetBuildResponse, bool) {
request := GetBuildRequest{
Info: n.getRunnerVersion(config),
Token: config.Token,
}
var response GetBuildResponse
result, statusText := n.do(config.RunnerCredentials, "POST", "builds/register.json", 201, &request, &response)
switch result {
case 201:
logrus.Println(config.ShortDescription(), "Checking for builds...", "received")
return &response, true
case 403:
logrus.Errorln(config.ShortDescription(), "Checking for builds...", "forbidden")
return nil, false
case 404:
logrus.Debugln(config.ShortDescription(), "Checking for builds...", "nothing")
return nil, true
case clientError:
logrus.Errorln(config.ShortDescription(), "Checking for builds...", "error:", statusText)
return nil, false
default:
logrus.Warningln(config.ShortDescription(), "Checking for builds...", "failed:", statusText)
return nil, true
}
}
开发者ID:mikew,项目名称:gitlab-ci-multi-runner,代码行数:27,代码来源:gitlab.go
示例10: createBuild
func (c *ExecCommand) createBuild(repoURL string, abortSignal chan os.Signal) (build *common.Build, err error) {
// Check if we have uncommitted changes
_, err = c.runCommand("git", "diff", "--quiet", "HEAD")
if err != nil {
logrus.Warningln("You most probably have uncommitted changes.")
logrus.Warningln("These changes will not be tested.")
}
// Parse Git settings
sha, err := c.runCommand("git", "rev-parse", "HEAD")
if err != nil {
return
}
beforeSha, err := c.runCommand("git", "rev-parse", "HEAD~1")
if err != nil {
beforeSha = "0000000000000000000000000000000000000000"
}
refName, err := c.runCommand("git", "rev-parse", "--abbrev-ref", "HEAD")
if err != nil {
return
}
build = &common.Build{
GetBuildResponse: common.GetBuildResponse{
ID: 1,
ProjectID: 1,
RepoURL: repoURL,
Commands: "",
Sha: strings.TrimSpace(sha),
RefName: strings.TrimSpace(refName),
BeforeSha: strings.TrimSpace(beforeSha),
AllowGitFetch: false,
Timeout: c.getTimeout(),
Token: "",
Name: "",
Stage: "",
Tag: false,
},
Runner: &common.RunnerConfig{
RunnerSettings: c.RunnerSettings,
},
SystemInterrupt: abortSignal,
}
return
}
开发者ID:bssthu,项目名称:gitlab-ci-multi-runner,代码行数:47,代码来源:exec.go
示例11: processRunner
func (mr *RunCommand) processRunner(id int, runner *common.RunnerConfig, runners chan *common.RunnerConfig) (err error) {
provider := common.GetExecutor(runner.Executor)
if provider == nil {
return
}
context, err := provider.Acquire(runner)
if err != nil {
log.Warningln("Failed to update executor", runner.Executor, "for", runner.ShortDescription(), err)
return
}
defer provider.Release(runner, context)
// Acquire build slot
if !mr.buildsHelper.acquire(runner) {
return
}
defer mr.buildsHelper.release(runner)
// Receive a new build
buildData, healthy := mr.network.GetBuild(*runner)
mr.makeHealthy(runner.UniqueID(), healthy)
if buildData == nil {
return
}
// Make sure to always close output
buildCredentials := &common.BuildCredentials{
ID: buildData.ID,
Token: buildData.Token,
}
trace := mr.network.ProcessBuild(*runner, buildCredentials)
defer trace.Fail(err)
// Create a new build
build := &common.Build{
GetBuildResponse: *buildData,
Runner: runner,
ExecutorData: context,
SystemInterrupt: mr.abortBuilds,
}
// Add build to list of builds to assign numbers
mr.buildsHelper.addBuild(build)
defer mr.buildsHelper.removeBuild(build)
// Process the same runner by different worker again
// to speed up taking the builds
select {
case runners <- runner:
mr.log().WithField("runner", runner.ShortDescription()).Debugln("Requeued the runner")
default:
mr.log().WithField("runner", runner.ShortDescription()).Debugln("Failed to requeue the runner: ")
}
// Process a build
return build.Run(mr.config, trace)
}
开发者ID:bssthu,项目名称:gitlab-ci-multi-runner,代码行数:59,代码来源:multi.go
示例12: processPaths
func (c *ArchiveCommand) processPaths() {
for _, path := range c.Paths {
matches, err := filepath.Glob(path)
if err != nil {
logrus.Warningln(err)
continue
}
for _, match := range matches {
err := filepath.Walk(match, func(path string, info os.FileInfo, err error) error {
return c.process(path)
})
if err != nil {
logrus.Warningln("Walking", match, err)
}
}
}
}
开发者ID:mikew,项目名称:gitlab-ci-multi-runner,代码行数:18,代码来源:archive.go
示例13: Warningln
func (e *AbstractExecutor) Warningln(args ...interface{}) {
// write to log file
if e.Build != nil {
e.Build.WriteString(helpers.ANSI_BOLD_YELLOW + "WARNING: " + fmt.Sprintln(args...) + helpers.ANSI_RESET)
}
args = append([]interface{}{e.Config.ShortDescription(), e.Build.ID}, args...)
log.Warningln(args...)
}
开发者ID:mikew,项目名称:gitlab-ci-multi-runner,代码行数:9,代码来源:executor_trace.go
示例14: getCacheStorageClient
func getCacheStorageClient(cache *common.CacheConfig) (scl *minio.Client, err error) {
scl, err = minio.New(cache.ServerAddress, cache.AccessKey, cache.SecretKey, cache.Insecure)
if err != nil {
logrus.Warningln(err)
return
}
scl.SetCustomTransport(&bucketLocationTripper{cache.BucketLocation})
return
}
开发者ID:bssthu,项目名称:gitlab-ci-multi-runner,代码行数:10,代码来源:cache.go
示例15: UploadRawArtifacts
func (m *testNetwork) UploadRawArtifacts(config common.BuildCredentials, reader io.Reader, baseName string, expireIn string) common.UploadState {
m.uploadCalled++
if m.uploadState == common.UploadSucceeded {
var buffer bytes.Buffer
io.Copy(&buffer, reader)
archive, err := zip.NewReader(bytes.NewReader(buffer.Bytes()), int64(buffer.Len()))
if err != nil {
logrus.Warningln(err)
return common.UploadForbidden
}
if len(archive.File) != 1 || archive.File[0].Name != artifactsTestArchivedFile {
logrus.Warningln("Invalid archive:", len(archive.File))
return common.UploadForbidden
}
}
return m.uploadState
}
开发者ID:bssthu,项目名称:gitlab-ci-multi-runner,代码行数:19,代码来源:artifacts_test.go
示例16: doRetry
func (r *retryHelper) doRetry(handler func() (bool, error)) (err error) {
retry, err := handler()
for i := 0; retry && i < r.Retry; i++ {
// wait one second to retry
logrus.Warningln("Retrying...")
time.Sleep(r.RetryTime)
retry, err = handler()
}
return
}
开发者ID:bssthu,项目名称:gitlab-ci-multi-runner,代码行数:10,代码来源:retry_helper.go
示例17: enqueueCheck
// place a check on the queue
func (sm *Manager) enqueueCheck(check stalker.Check) {
cb, err := json.Marshal(check)
stalker.OnlyLogIf(err)
rconn := sm.rpool.Get()
defer rconn.Close()
res, err := rconn.Do("RPUSH", "worker1", cb)
log.Debugln("Checks now on queue:", res)
if err != nil {
log.Warningln("error pushing check on queue:", err)
}
}
开发者ID:pandemicsyn,项目名称:stalker,代码行数:12,代码来源:manager.go
示例18: isFileChanged
func (c *fileArchiver) isFileChanged(fileName string) bool {
ai, err := os.Stat(fileName)
if ai != nil {
if !c.isChanged(ai.ModTime()) {
return false
}
} else if !os.IsNotExist(err) {
logrus.Warningln(err)
}
return true
}
开发者ID:bssthu,项目名称:gitlab-ci-multi-runner,代码行数:11,代码来源:file_archiver.go
示例19: pauseIfAsked
// Check if pause file exists and sleep until its removed if it does
func (sm *Manager) pauseIfAsked() {
if stalker.FExists(sm.pauseFile) {
log.Warningln("Pausing")
for {
time.Sleep(1 * time.Second)
if !stalker.FExists(sm.pauseFile) {
return
}
}
}
}
开发者ID:pandemicsyn,项目名称:stalker,代码行数:12,代码来源:manager.go
示例20: getS3UploadURL
func getS3UploadURL(build *common.Build, key string) (url *url.URL) {
cache := build.Runner.Cache
objectName := getCacheObjectName(build, cache, key)
if objectName == "" {
return
}
scl, err := getCacheStorageClient(cache)
if err != nil {
logrus.Warningln(err)
return
}
url, err = scl.PresignedPutObject(cache.BucketName, objectName, time.Second*time.Duration(build.Timeout))
if err != nil {
logrus.Warningln(err)
return
}
return
}
开发者ID:bssthu,项目名称:gitlab-ci-multi-runner,代码行数:20,代码来源:cache.go
注:本文中的github.com/Sirupsen/logrus.Warningln函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论