當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Logger.Warn方法代碼示例

本文整理匯總了Golang中github.com/cortesi/devd/termlog.Logger.Warn方法的典型用法代碼示例。如果您正苦於以下問題:Golang Logger.Warn方法的具體用法?Golang Logger.Warn怎麽用?Golang Logger.Warn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/cortesi/devd/termlog.Logger的用法示例。


在下文中一共展示了Logger.Warn方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: shouldInclude

// Determine if a file should be included, based on the given exclude paths.
func shouldInclude(file string, excludePatterns []string, log termlog.Logger) bool {
	for _, pattern := range excludePatterns {
		match, err := doublestar.Match(pattern, file)
		if err != nil {
			log.Warn("Error matching pattern '%s': %s", pattern, err)
		} else if match {
			return false
		}
	}
	return true
}
開發者ID:wzugang,項目名稱:devd,代碼行數:12,代碼來源:watch.go

示例2: shouldInclude

// Determine if a file should be included, based on the given exclude paths.
func shouldInclude(file string, excludePatterns []string, log termlog.Logger) bool {
	for _, pattern := range excludePatterns {
		match, err := filepath.Match(pattern, file)

		if err != nil {
			log.Warn("Invalid pattern: `%s'", pattern)
		} else if match {
			return false
		}
	}

	return true
}
開發者ID:skyfree02,項目名稱:devd,代碼行數:14,代碼來源:watch.go

示例3: serveFile

// name is '/'-separated, not filepath.Separator.
func (fserver *FileServer) serveFile(
	logger termlog.Logger,
	w http.ResponseWriter,
	r *http.Request,
	name string,
	redirect bool,
) {
	const indexPage = "/index.html"

	// redirect .../index.html to .../
	// can't use Redirect() because that would make the path absolute,
	// which would be a problem running under StripPrefix
	if strings.HasSuffix(r.URL.Path, indexPage) {
		logger.SayAs(
			"debug", "debug fileserver: redirecting %s -> ./", indexPage,
		)
		localRedirect(w, r, "./")
		return
	}

	f, err := fserver.Root.Open(name)
	if err != nil {
		logger.WarnAs("debug", "debug fileserver: %s", err)
		if err := notFound(fserver.Inject, fserver.Templates, w); err != nil {
			logger.Shout("Internal error: %s", err)
		}
		return
	}
	defer f.Close()

	d, err1 := f.Stat()
	if err1 != nil {
		logger.WarnAs("debug", "debug fileserver: %s", err)
		if err := notFound(fserver.Inject, fserver.Templates, w); err != nil {
			logger.Shout("Internal error: %s", err)
		}
		return
	}

	if redirect {
		// redirect to canonical path: / at end of directory url
		// r.URL.Path always begins with /
		url := r.URL.Path
		if d.IsDir() {
			if url[len(url)-1] != '/' {
				localRedirect(w, r, path.Base(url)+"/")
				return
			}
		} else {
			if url[len(url)-1] == '/' {
				localRedirect(w, r, "../"+path.Base(url))
				return
			}
		}
	}

	// use contents of index.html for directory, if present
	if d.IsDir() {
		index := name + indexPage
		ff, err := fserver.Root.Open(index)
		if err == nil {
			defer ff.Close()
			dd, err := ff.Stat()
			if err == nil {
				name = index
				d = dd
				f = ff
			}
		}
	}

	// Still a directory? (we didn't find an index.html file)
	if d.IsDir() {
		if checkLastModified(w, r, d.ModTime()) {
			return
		}
		dirList(fserver.Inject, logger, w, name, f, fserver.Templates)
		return
	}

	// serverContent will check modification time
	sizeFunc := func() (int64, error) { return d.Size(), nil }
	err = serveContent(fserver.Inject, w, r, d.Name(), d.ModTime(), sizeFunc, f)
	if err != nil {
		logger.Warn("Error serving file: %s", err)
	}
}
開發者ID:rawbite,項目名稱:devd,代碼行數:88,代碼來源:fileserver.go

示例4: testpatt

func testpatt(l termlog.Logger) {
	l.Say("Log")
	l.Notice("Notice!")
	l.Warn("Warn!")
	l.Shout("Error!")
}
開發者ID:npk,項目名稱:devd,代碼行數:6,代碼來源:termlog_demo.go


注:本文中的github.com/cortesi/devd/termlog.Logger.Warn方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。