dnote/log/log.go
Sung Won Cho 41ee8eba0f
Use editor for add and edit by default (#54)
* Open text editor for add and edit

* Remove unused test

* Improve output

* Remove support for current book

* Improve ls output and add an alias

* Simplify logic

* v0.2.0-alpha.3

* Add migration for editor

* Add ASCII art
2018-01-09 21:31:52 +11:00

55 lines
1.3 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package log
import (
"fmt"
)
var (
ColorRed = 31
ColorGreen = 32
ColorYellow = 33
ColorBlue = 34
ColorGray = 37
)
var indent = " "
func Info(msg string) {
fmt.Printf("%s\033[%dm%s\033[0m %s\n", indent, ColorBlue, "•", msg)
}
func Infof(msg string, v ...interface{}) {
fmt.Printf("%s\033[%dm%s\033[0m %s", indent, ColorBlue, "•", fmt.Sprintf(msg, v...))
}
func Success(msg string) {
fmt.Printf("%s\033[%dm%s\033[0m %s", indent, ColorGreen, "✔", msg)
}
func Successf(msg string, v ...interface{}) {
fmt.Printf("%s\033[%dm%s\033[0m %s", indent, ColorGreen, "✔", fmt.Sprintf(msg, v...))
}
func Plain(msg string) {
fmt.Printf("%s%s", indent, msg)
}
func Plainf(msg string, v ...interface{}) {
fmt.Printf("%s%s", indent, fmt.Sprintf(msg, v...))
}
func Warnf(msg string, v ...interface{}) {
fmt.Printf("%s\033[%dm%s\033[0m %s", indent, ColorRed, "•", fmt.Sprintf(msg, v...))
}
func Error(msg string) {
fmt.Printf("%s\033[%dm%s\033[0m %s\n", indent, ColorRed, "", msg)
}
func Printf(msg string, v ...interface{}) {
fmt.Printf("%s\033[%dm%s\033[0m %s", indent, ColorGray, "•", fmt.Sprintf(msg, v...))
}
func WithPrefixf(prefixColor int, prefix, msg string, v ...interface{}) {
fmt.Printf(" \033[%dm%s\033[0m %s\n", prefixColor, prefix, fmt.Sprintf(msg, v...))
}