• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

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

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: ShowColor

// 将图片渲染到文字(有颜色版)
func ShowColor(iw io.Writer, img image.Image, console Console) {
	// Lanczos3缩放图片到控制台屏幕大小
	w := console.ScreenW - 1 // 标宽 换行符竟然也算一个?
	s := img.Bounds().Size()
	// 标高 = 结果高 * 宽高比 = (原高 / 原宽 * 标宽) * 宽高比
	h := uint(float64(s.Y) / float64(s.X) * float64(w) * console.Ratio())
	m := resize.Resize(w, h, img, resize.Bicubic)
	for y := 0; y < int(h); y++ {
		for x := (0); x < int(w); x++ {
			r, g, b, a := m.At(x, y).RGBA()
			r, g, b, a = r>>10, g>>10, b>>10, a>>10 // 转换到6位色 0~63
			r, g, b = r*a/63, g*a/63, b*a/63        // Alpha混合
			m, fg, fgl, bg, bgl := GetConsoleColor(r, g, b)
			ct.ChangeColor(fg, fgl, bg, bgl)
			// cindex := (r + g + b) / 3
			io.WriteString(iw, clist64[m:m+1])
		}
		io.WriteString(iw, "\n")
	}
	ct.ResetColor()
}
开发者ID:pa001024,项目名称:reflex,代码行数:22,代码来源:ShowImage.go


示例17: Write

func (t *textLogger) Write(entry Entry) {
	if t.ttyOutput {
		ct.ChangeColor(entry.Level.Color, entry.Level.Bright, ct.None, false)
	}
	text := strings.TrimSpace(entry.Message)
	if entry.Level.Level >= WarnLevel.Level {
		text = fmt.Sprintf("[%s from %s]\n", entry.ID, entry.Origin) + text
	}
	if strings.Contains(text, "\n") { // separate multiline comments with newlines
		if !t.lastNewline {
			fmt.Fprintln(t.out) // separate from previous one-line log msg
		}
		text = text + "\n"
		t.lastNewline = true
	} else {
		t.lastNewline = false
	}
	fmt.Fprintln(t.out, entry.Level.Prefix+strings.Replace(text, "\n", "\n       ", -1))
	if t.ttyOutput {
		ct.ResetColor()
	}
}
开发者ID:RomainVabre,项目名称:origin,代码行数:22,代码来源:text.go


示例18: PrintFull

func (e *PhpLogEvent) PrintFull() {
	fmt.Printf("\n---------- PHP LOG EVENT ----------\n")

	writer := new(tabwriter.Writer)
	writer.Init(os.Stdout, 0, 8, 2, ' ', 0)

	fmt.Fprintf(
		writer,
		"SyslogTime:\t%s\n",
		e.SyslogTime.Format("2006-01-02 15:04:05"),
	)

	fmt.Fprintf(writer, "LogLevel:\t%s\n", e.LogLevel)
	fmt.Fprintf(writer, "Content:\t%s\n", e.Content)
	fmt.Fprintf(writer, "File:\t%s\n", e.File)
	fmt.Fprintf(writer, "Line:\t%d\n", e.Line)

	writer.Flush()

	ct.ChangeColor(ct.White, true, ct.None, false)
	fmt.Print("\nStack trace\n")
	ct.ResetColor()

	for _, phpStackTraceLogEvent := range e.StackTraceEvents {
		fmt.Fprintf(
			writer,
			"%d.\t%s\t%s\t%d\n",
			phpStackTraceLogEvent.Number,
			phpStackTraceLogEvent.Method,
			phpStackTraceLogEvent.File,
			phpStackTraceLogEvent.Line,
		)
	}

	writer.Flush()

	fmt.Printf("\n---------- PHP LOG EVENT ----------\n")
}
开发者ID:lovek323,项目名称:bclog,代码行数:38,代码来源:php.go


示例19: Error

func Error(format string, a ...interface{}) {
	defer color.ResetColor()

	color.Foreground(color.Red, true)
	fmt.Println(fmt.Sprintf(format, a...))
}
开发者ID:kapitanov,项目名称:logtail,代码行数:6,代码来源:printer.go


示例20: displayMessage

func (c *coloredConsole) displayMessage(msg string, color ct.Color) {
	ct.Foreground(color, false)
	defer ct.ResetColor()
	fmt.Fprint(c.writer, msg)
	c.writer.Print()
}
开发者ID:mattdotmatt,项目名称:gauge,代码行数:6,代码来源:coloredConsole.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang sophie.FsPath类代码示例发布时间:2022-05-23
下一篇:
Golang doc.HttpClient类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap