当前位置: 首页>>代码示例>>Golang>>正文


Golang go-colortext.ResetColor函数代码示例

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


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

示例1: Print

func (tokens LogTokens) Print() {
	defer color.ResetColor()

	var defColor color.Color = color.White
	var defBright bool = true

	for _, token := range tokens {
		if token.Type >= TOKEN_DEBUG {
			defColor, defBright, _ = token.Type.getFgColor()
		}
	}

	for _, token := range tokens {
		fg, bright, specific := token.Type.getFgColor()
		if !specific {
			fg = defColor
			bright = defBright
		}

		color.Foreground(fg, bright)
		fmt.Print(token.Text)
	}

	fmt.Print("\n")
}
开发者ID:kapitanov,项目名称:logtail,代码行数:25,代码来源:printer.go

示例2: init

func init() {
	defer ct.ResetColor()
	//	WriteOutLevel(OUT_LEVEL_WARNING)
	//	WriteOut("#####################################\n  Chandra Application")
	//	WriteOut("\n#####################################\n")
	//	WriteOutLevel(OUT_LEVEL_RESET)
}
开发者ID:wgq91here,项目名称:chandra,代码行数:7,代码来源:console.go

示例3: outputColorStack

// outputColorStack is use when -logcolor is enabled.
// colored stack printing is allowed to be inefficient because it's a local development feature.
func outputColorStack(stacks []byte, s severity) {
	r := bytes.NewReader(stacks)
	scanner := bufio.NewScanner(r)
	for scanner.Scan() {
		l := scanner.Bytes()
		if len(l) > 0 && l[0] == "\t"[0] {
			addroffset := bytes.LastIndex(l, []byte(" "))
			linumoffset := bytes.LastIndex(l, []byte(":"))
			if addroffset == -1 || linumoffset == -1 {
				os.Stderr.Write(l)
				goto eol
			}
			srcpath := l[0:linumoffset]
			hlstart := 0
			hlstacksrc.Lock()
			if hlstacksrc.v != nil {
				for _, v := range hlstacksrc.v {
					offs := bytes.Index(srcpath, v)
					if offs > hlstart {
						hlstart = offs
					}
				}
			}
			hlstacksrc.Unlock()
			if hlstart > 0 {
				os.Stderr.Write(srcpath[:hlstart])
				ct.Foreground(ct.Blue, true)
				os.Stderr.Write(srcpath[hlstart:])
				ct.ResetColor()
			} else {
				os.Stderr.Write(srcpath)
			}
			os.Stderr.WriteString(":")
			printColor(s)
			os.Stderr.Write(l[linumoffset+1 : addroffset])
			ct.ResetColor()
			os.Stderr.Write(l[addroffset:])
		} else {
			os.Stderr.Write(l)
		}
	eol:
		os.Stderr.WriteString("\n")
	}
	if err := scanner.Err(); err != nil {
		fmt.Fprintln(os.Stderr, "reading standard input:", err)
	}
}
开发者ID:gitter-badger,项目名称:alkasir,代码行数:49,代码来源:glog.go

示例4: WriteOut

func WriteOut(s string, ars ...interface{}) {
	if len(ars) > 0 {
		fmt.Printf(s, ars)
	} else {
		fmt.Print(s)
	}
	ct.ResetColor()
}
开发者ID:wgq91here,项目名称:chandra,代码行数:8,代码来源:console.go

示例5: WriteLine

// Write out a single coloured line
func (of *OutletFactory) WriteLine(left, right string, leftC, rightC ct.Color, isError bool) {
	of.Lock()
	defer of.Unlock()

	ct.ChangeColor(leftC, true, ct.None, false)
	formatter := fmt.Sprintf("%%-%ds | ", of.Padding)
	fmt.Printf(formatter, left)

	if isError {
		ct.ChangeColor(ct.Red, true, ct.None, true)
	} else {
		ct.ResetColor()
	}
	fmt.Println(right)
	if isError {
		ct.ResetColor()
	}
}
开发者ID:commonnet,项目名称:forego,代码行数:19,代码来源:outlet.go

示例6: PrintLine

func (e *BigcommerceAppLogEvent) PrintLine(index int) {
	fmt.Printf("[%d]  ", index)
	fmt.Printf("%s  ", e.SyslogTime.Format("2006-01-02 15:04:05"))
	ct.ChangeColor(ct.Yellow, false, ct.None, false)
	fmt.Print("bigcommerce-app  ")
	ct.ChangeColor(ct.Cyan, false, ct.None, false)
	fmt.Printf("%s-%d  ", e.LogLevel, e.StoreContext.StoreId)
	ct.ResetColor()
	fmt.Printf("%s\n", e.Content)
}
开发者ID:lovek323,项目名称:bclog,代码行数:10,代码来源:bigcommerce-app.go

示例7: PrintLine

func (e *GenericLogEvent) PrintLine(index int) {
	fmt.Printf("[%d]  ", index)
	fmt.Print(e.SyslogTime.Format("2006-01-02 15:04:05") + "  ")
	ct.ChangeColor(ct.Yellow, false, ct.None, false)
	fmt.Print("generic  ")
	ct.ChangeColor(ct.Cyan, false, ct.None, false)
	fmt.Printf("%s  ", e.Name)
	ct.ResetColor()
	fmt.Printf("%s\n", e.Content)
}
开发者ID:lovek323,项目名称:bclog,代码行数:10,代码来源:generic.go

示例8: PrintLine

func (e *ProcessLogEvent) PrintLine(index int) {
	fmt.Printf("[%d]  ", index)
	fmt.Print(e.SyslogTime.Format("2006-01-02 15:04:05") + "  ")
	ct.ChangeColor(ct.Yellow, false, ct.None, false)
	fmt.Print("process  ")
	ct.ChangeColor(ct.Cyan, false, ct.None, false)
	fmt.Printf("%s-%d  ", e.Name, e.ProcessId)
	ct.ResetColor()
	fmt.Printf("%s\n", e.Content)
}
开发者ID:lovek323,项目名称:bclog,代码行数:10,代码来源:process.go

示例9: PrintLine

func (e *PhpStackTraceLogEvent) PrintLine(index int) {
	fmt.Printf("[%d]  ", index)
	fmt.Print(e.SyslogTime.Format("2006-01-02 15:04:05") + "  ")
	ct.ChangeColor(ct.Yellow, false, ct.None, false)
	fmt.Print("php-stack-trace  ")
	ct.ChangeColor(ct.Cyan, false, ct.None, false)
	fmt.Printf("%d-%s-%d  ", e.Number, e.File, e.Line)
	ct.ResetColor()
	fmt.Printf("%s\n", e.Method)
}
开发者ID:lovek323,项目名称:bclog,代码行数:10,代码来源:php.go

示例10: WriteOutLevel

func WriteOutLevel(l string) {
	switch l {
	case OUT_LEVEL_WARNING:
		ct.ChangeColor(ct.Yellow, true, ct.None, false)
	case OUT_LEVEL_ERROR:
		ct.ChangeColor(ct.Red, true, ct.None, false)
	case OUT_LEVEL_INFO:
		ct.ChangeColor(ct.Cyan, true, ct.None, false)
	default:
		ct.ResetColor()
	}
}
开发者ID:wgq91here,项目名称:chandra,代码行数:12,代码来源:console.go

示例11: print

func print(timeFormat string, le *logEntry) {
	var level string
	switch le.level {
	case Info:
		level = "INFO    "
		ct.Foreground(ct.Cyan, false)
	case Warning:
		level = "WARNING "
		ct.Foreground(ct.Yellow, false)
	case Error:
		level = "ERROR   "
		ct.Foreground(ct.Red, false)
	case Critical:
		level = "CRITICAL"
		ct.ChangeColor(ct.Black, false, ct.Red, false)
	case Fatal:
		level = "FATAL   "
		ct.ResetColor()
	}
	fmt.Println(le.time.Format(timeFormat), level, le.message)
	ct.ResetColor()
}
开发者ID:robsix,项目名称:golog,代码行数:22,代码来源:golog.go

示例12: PrintLine

func (e *NginxErrorLogEvent) PrintLine(index int) {
	fmt.Printf("[%d]  ", index)

	if e.LogLevel == "error" {
		fmt.Print(e.SyslogTime.Format("2006-01-02 15:04:05") + "  ")
		ct.ChangeColor(ct.Yellow, false, ct.Red, false)
		fmt.Print("nginx-error  ")
		ct.ChangeColor(ct.Cyan, false, ct.Red, false)
		fmt.Printf("%s  ", e.LogLevel)
		ct.ChangeColor(ct.None, false, ct.Red, false)
		fmt.Printf("%s %s\n", e.Request.Uri, e.Content)
		ct.ResetColor()
	} else {
		fmt.Print(e.SyslogTime.Format("2006-01-02 15:04:05") + "  ")
		ct.ChangeColor(ct.Yellow, false, ct.None, false)
		fmt.Print("nginx-error  ")
		ct.ChangeColor(ct.Cyan, false, ct.None, false)
		fmt.Printf("%s  ", e.LogLevel)
		ct.ResetColor()
		fmt.Printf("%s %s\n", e.Request.Uri, e.Content)
	}
}
开发者ID:lovek323,项目名称:bclog,代码行数:22,代码来源:nginx.go

示例13: ScenarioStart

func (cl *coloredLogger) ScenarioStart(scenarioHeading string) {
	msg := formatScenario(scenarioHeading)
	Log.Info(msg)

	indentedText := indent(msg, scenarioIndentation)
	if level == logging.INFO {
		cl.headingText.WriteString(indentedText + spaces(4))
		cl.writeToConsole(cl.headingText.String(), ct.None, false)
	} else {
		ct.Foreground(ct.Yellow, false)
		ConsoleWrite(indentedText)
		ct.ResetColor()
	}
}
开发者ID:jasonchaffee,项目名称:gauge,代码行数:14,代码来源:coloredLogger.go

示例14: ColoredPrint

// A simple function to print message with colors.
func ColoredPrint(thecolor color.Color, bold bool, values ...interface{}) {

	// change the color of the terminal
	color.ChangeColor(
		thecolor,
		bold,
		None,
		false,
	)

	// print
	fmt.Print(values...)

	// reset the color
	color.ResetColor()
}
开发者ID:ElricleNecro,项目名称:TOD,代码行数:17,代码来源:formatter.go

示例15: TestGetConsoleColor

func TestGetConsoleColor(t *testing.T) {
	for b := uint32(0); b < 6; b++ {
		for g := uint32(0); g < 6; g++ {
			for r := uint32(0); r < 6; r++ {
				m, l, h, j, k := GetConsoleColor(r*0x33/4, g*0x33/4, b*0x33/4)
				ct.ChangeColor(l, h, j, k)
				c := clist64[m : m+1]
				c = c + c + c + c
				if k {
					fmt.Printf("%s%x", c, (j-1)<<1)
				} else {
					fmt.Printf("%s%x", c, (j - 1))
				}
				ct.ResetColor()
				fmt.Printf("#%02x%02x%02x ", r*0x33, g*0x33, b*0x33)
			}
			fmt.Print("\n")
		}
	}
}
开发者ID:pa001024,项目名称:reflex,代码行数:20,代码来源:ShowImage_test.go


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