zoukankan      html  css  js  c++  java
  • 后端程序员之路 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
    ") //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")
        }
    }
    

      

  • 相关阅读:
    Using zend-paginator in your Album Module
    Using zend-navigation in your Album Module
    Unit Testing a zend-mvc application
    Conclusion
    Forms and actions
    Database and models
    Routing and controllers
    Modules
    Java开发的基础条件:
    com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 数据库报错
  • 原文地址:https://www.cnblogs.com/zapline/p/7736044.html
Copyright © 2011-2022 走看看