Giter VIP home page Giter VIP logo

fion's Introduction

Fion

Fion is a log module for golang, provides different foreground color, background color, font control methods.

Color, Font Control

Fion provides multiple color and font control methods to display output, as follows:

    //[Secion 1]
    fmt.Printf("%s\n", fion.Black("%d %d", 100, 200))
    fmt.Printf("%s\n", fion.Red("%d %d", 100, 200))
    fmt.Printf("%s\n", fion.Green("%d %d", 100, 200))
    fmt.Printf("%s\n", fion.Yellow("%d %d", 100, 200))
    fmt.Printf("%s\n", fion.Blue("%d %d", 100, 200))
    fmt.Printf("%s\n", fion.Magenta("%d %d", 100, 200))
    fmt.Printf("%s\n", fion.Cyan("%d %d", 100, 200))
    fmt.Printf("%s\n", fion.White("%d %d", 100, 200))

    //[Secion 2]
    fmt.Printf("%s %s\n", fion.Underline("Important"), fion.CrossedOut("Something Wrong"))

    //[Secion 3] Also you can use like this
    fmt.Printf("%s\n", fion.SlowBlink(fion.Red("Error!!!")))

In section 3, it's hard to use if you want use it on many place, so Fion offers you to custimize your own format:

    doublyUnderlineBlue := fion.NewFormat(fion.SDoublyUnderline, fion.SFDBlue)
    fmt.Println("%s\n", doublyUnderlineBlue("[WoW] Blue Doubly Underline"))

Tag

There are few default tags, includes:

  • Trace, Tracef
  • Debug, Debugf
  • Info, Infof
  • Warn, Warnf
  • Error, Errorf

And Fion also provide customize method to create your own tag.

    //Use Fion provides tags
    fion.Trace("Where's Septem ?")
    fion.Debugf("Home with his %s.", "PS4")
    fion.Info("What's game he playing now ?")
    fion.Warnf("RDR%d", 2)
    fion.Errorf("loooooooooool")

    Notice, Noticef := fion.NewTag("[NOTICE]", 10, fion.SBBGreen, fion.SFBRed, fion.SInverse)
    Notice("Fion so Cooooooooooooooooooooool!!!")
    Noticef("u r running %x", 3735929054)

Fion tag also has level mechanism, default level setup to 2(Info), you can use SetTagLevel to change it.

    fion.Trace("Trace 0")       // Wouldn't show on your console
    fion.Debugf("Debug %d", 1)  // Wouldn't show on your console
    fion.Infof("Info %d", 2)    // Would show on your console
    fion.Warn("Warn 3")         // Would show on your console
    fion.Error("Error 4")       // Would show on your console

    //Let's change tag level, and run the same code section
    fion.SetTagLevel(0)

    fion.Trace("Trace 0")       // Would show on your console
    fion.Debugf("Debug %d", 1)  // Would show on your console
    fion.Infof("Info %d", 2)    // Would show on your console
    fion.Warn("Warn 3")         // Would show on your console
    fion.Error("Error 4")       // Would show on your console

fion's People

Contributors

septemhill avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.