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


Golang TextFormatter.DisableColors方法代碼示例

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


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

示例1: init

func init() {
	formatter := log.TextFormatter{}
	formatter.DisableTimestamp = false
	formatter.DisableColors = true
	log.SetFormatter(&formatter)
	//log.SetLevel(log.InfoLevel)
}
開發者ID:chenhuaying,項目名稱:logflume,代碼行數:7,代碼來源:logflume.go

示例2: LogInit

// LogInit is a utility function to initialize logging
func LogInit(filename string) {
	f, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
	if err != nil {
		log.Fatal("Unable to open Log file ", err)
	}
	Logger.Out = f
	customFormatter := new(logrus.TextFormatter)
	customFormatter.TimestampFormat = "2016-03-28 15:04:05"
	Logger.Formatter = customFormatter
	customFormatter.FullTimestamp = true
	customFormatter.DisableColors = true
}
開發者ID:aravindavk,項目名稱:glusterrest_old,代碼行數:13,代碼來源:utils.go

示例3: makeJournal

// Build an adequate instance of the structured logger for this
// application instance. The journal builder may draw data from the
// app instance to configure the journal correctly. This method only
// instantiates a very basic journal; anything more complicated than
// that should be implementing using a boot.Provider to do it.
func (app *App) makeJournal(level logrus.Level) *logrus.Logger {
	const m = "begin writing application journal"
	var journal *logrus.Logger = &logrus.Logger{}
	formatter := new(logrus.TextFormatter)  // std
	journal.Level = level                   // use requested level
	journal.Out = os.Stdout                 // all goes to stdout
	journal.Hooks = make(logrus.LevelHooks) // empty
	journal.Formatter = formatter           // set formatter
	formatter.ForceColors = false           // act smart
	formatter.DisableColors = false         // make pretty
	formatter.DisableTimestamp = false      // is useful
	formatter.FullTimestamp = false         // numbers
	formatter.TimestampFormat = time.StampMilli
	formatter.DisableSorting = false // order!
	moment := time.Now().Format(app.TimeLayout)
	journal.WithField("time", moment).Info(m)
	return journal // is ready to use
}
開發者ID:ts33kr,項目名稱:boot,代碼行數:23,代碼來源:app.go

示例4: makeLogger

// makeLogger configures the package level Logger instance
func makeLogger(conf *BaseConfiguration) {
	levelName, err := logrus.ParseLevel(conf.LogLevel)
	if err != nil {
		defer Logger.Warnf("%s is not a valid level. Defaulting to info.", conf.LogLevel)
		levelName = logrus.InfoLevel
	}

	logOut, err := os.OpenFile(conf.LogFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)

	if err != nil {
		defer Logger.Warnf("%s. Defaulting to Stderr.", err)
		logOut = os.Stderr
	}

	formatter := new(logrus.TextFormatter)
	formatter.DisableColors = true
	Logger = logrus.Logger{
		Out:       logOut,
		Formatter: formatter,
		Level:     levelName,
	}
	Logger.Infof("Initialized at level %s", Logger.Level)
}
開發者ID:pombredanne,項目名稱:go-serv,代碼行數:24,代碼來源:server.go


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