后端程序员之路 58、go wlog
daviddengcn/go-colortext: Change the color of console text.
https://github.com/daviddengcn/go-colortext
dixonwille/wlog: A simple logging interface that supports cross-platform color and concurrency.
https://github.com/dixonwille/wlog
package main import (
"strings"
"os"
. "github.com/dixonwille/wlog"
) func TestWLog() {
var ui UI
reader := strings.NewReader("User Input\r\n") //Simulate user typing "User Input" then pressing [enter] when reading from os.Stdin
ui = New(reader, os.Stdout, os.Stdout)
ui = AddConcurrent(ui) var addPrefixCases = []struct {
ask string
err string
inf string
log string
out string
suc string
run string
war string
}{
{" ", " ", " ", " ", " ", " ", " ", " "},
{" ", " ", " ", " ", " ", " ", " ", " "},
{Cross, Check, "!", "~", "@", "#", "+", "="},
{"%", "^", "&", "*", "@", ":", ",", "?"},
}
for _, c := range addPrefixCases {
prefix := AddPrefix(c.ask, c.err, c.inf, c.log, c.out, c.run, c.suc, c.war, ui)
prefix.Ask("Ask question", "")
prefix.Error("Error message")
prefix.Info("Info message")
prefix.Output("Output message")
prefix.Running("Running message")
prefix.Success("Success message")
prefix.Warn("Warning message")
} var addColorCases = []struct {
logColor Color
outputColor Color
successColor Color
infoColor Color
errorColor Color
warnColor Color
runningColor Color
askColor Color
responseColor Color
}{
{None, Blue, Green, Red, Yellow, Cyan, Magenta, White, Black},
{BrightBlue, BrightGreen, BrightRed, BrightYellow, BrightCyan, BrightMagenta, BrightWhite, BrightBlack, None},
}
for _, c := range addColorCases {
color := AddColor(c.askColor, c.errorColor, c.infoColor, c.logColor, c.outputColor, c.responseColor, c.runningColor, c.successColor, c.warnColor, ui)
color.Ask("Ask question", "")
color.Error("Error message")
color.Info("Info message")
color.Output("Output message")
color.Running("Running message")
color.Success("Success message")
color.Warn("Warning message")
}
}
后端程序员之路 58、go wlog的更多相关文章
- 后端程序员之路 59、go uiprogress
gosuri/uiprogress: A go library to render progress bars in terminal applicationshttps://github.com/g ...
- 后端程序员之路 43、Redis list
Redis数据类型之LIST类型 - Web程序猿 - 博客频道 - CSDN.NEThttp://blog.csdn.net/thinkercode/article/details/46565051 ...
- 后端程序员之路 22、RESTful API
理解RESTful架构 - 阮一峰的网络日志http://www.ruanyifeng.com/blog/2011/09/restful.html RESTful API 设计指南 - 阮一峰的网络日 ...
- 后端程序员之路 16、信息熵 、决策树、ID3
信息论的熵 - guisu,程序人生. 逆水行舟,不进则退. - 博客频道 - CSDN.NEThttp://blog.csdn.net/hguisu/article/details/27305435 ...
- 后端程序员之路 7、Zookeeper
Zookeeper是hadoop的一个子项目,提供分布式应用程序协调服务. Apache ZooKeeper - Homehttps://zookeeper.apache.org/ zookeeper ...
- 后端程序员之路 4、一种monitor的做法
record_t包含_sum._count._time_stamp._max._min最基础的一条记录,可以用来记录最大值.最小值.计数.总和metric_t含有RECORD_NUM(6)份recor ...
- 后端程序员之路 57、go json
go自带json处理库,位于encoding/json,里面的test很具参考意义,特别是example_test.go json - The Go Programming Languagehttps ...
- 后端程序员之路 56、go package
package分包.import导入包import . "package1" 省略前缀包名import p1 "package1" 起别名import _ & ...
- 后端程序员之路 55、go redis
redigo有点像hiredis,只提供了最基本的连接和执行命令接口. 找到个不错的redis库: https://github.com/go-redis/redis func ExampleNewC ...
随机推荐
- Centos根目录100%解决思路
Centos 7 根目录(爆满)100%解决思路,下面以宝塔面板环境为例 1.首先远程到服务器,在~下输入df -h ,看下根目录下文件夹使用情况 [root@localhost~]# df -h F ...
- 【洛谷 p3379】模板-最近公共祖先(图论--倍增算法求LCA)
题目:给定一棵有根多叉树,请求出指定两个点直接最近的公共祖先. 解法:倍增. 1 #include<cstdio> 2 #include<cstdlib> 3 #include ...
- 【luogu AT3957】[AGC023F] 01 on Tree
01 on Tree 题目链接:luogu AT3957 题目大意 有一棵根为 \(1\) 的树,每个节点有个值 \(0\) 或 \(1\). 然后每次你可以把一个没有父亲的点删除,然后把值放进一个数 ...
- 大数据去重(data deduplication)方案
数据去重(data deduplication)是大数据领域司空见惯的问题了.除了统计UV等传统用法之外,去重的意义更在于消除不可靠数据源产生的脏数据--即重复上报数据或重复投递数据的影响,使计算产生 ...
- ysoserial Commons Collections2反序列化研究
Apache Commons Collections2反序列化研究 环境准备 JDK 1.7 Commons Collections 4.0 javassit 前置知识 PriorityQueue() ...
- 使用LCX进行内网端口转发
Lcx.exe是一个端口转发工具,相当于把目标服务器A上的3389端口转发到具有外网ip地址的B机上(即我们自己的主机或是已经控制的主机),这样链接B机的3389端口就相当于链接A机的3389端口了, ...
- Bazinga means
Bazinga means Bazinga https://www.dictionary.com/e/slang/bazinga/ refs xgqfrms 2012-2020 www.cnblogs ...
- Flow All In One
Flow All In One Flow is a static type checker for JavaScript https://github.com/facebook/flow https: ...
- webpack-cli bugs All In One
webpack-cli bugs All In One Error: Cannot find module 'webpack-cli/bin/config-yargs' webpack version ...
- flutter package & pub publish
flutter package & pub publish dart-library-package https://pub.dev/packages/dart_library_package ...