本文整理汇总了Golang中github.com/Sirupsen/logrus.Warningln函数的典型用法代码示例。如果您正苦于以下问题:Golang Warningln函数的具体用法?Golang Warningln怎么用?Golang Warningln使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Warningln函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
}
}
示例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)
}
}
示例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:
}
}
示例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
}
}
示例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
}
示例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)
}
}
}
示例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.")
}
}
}
示例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)
}
示例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
}
}
示例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
}
示例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)
}
示例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)
}
}
}
}
示例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...)
}
示例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
}
示例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
}