Documentation
¶
Index ¶
Examples ¶
Constants ¶
View Source
const ( LOG_LEVEL_DEBUG = "DEBUG" LOG_LEVEL_INFO = "INFO" LOG_LEVEL_WARN = "WARN" LOG_LEVEL_ERROR = "ERROR" )
Variables ¶
This section is empty.
Functions ¶
func FormatCount ¶ added in v0.0.2
Example ¶
package main
import (
"fmt"
"github.com/OutOfBedlam/tine/util"
)
func main() {
fmt.Println(util.FormatCount(0, util.CountUnitLines))
fmt.Println(util.FormatCount(1, util.CountUnitLines))
fmt.Println(util.FormatCount(2, util.CountUnitLines))
}
Output: 0 lines 1 line 2 lines
func FormatFileSize ¶
ByteSize returns a human-readable byte size string.
Example ¶
package main
import (
"fmt"
"github.com/OutOfBedlam/tine/util"
)
func main() {
fmt.Println(util.FormatFileSize(0))
fmt.Println(util.FormatFileSize(1))
fmt.Println(util.FormatFileSize(1024))
fmt.Println(util.FormatFileSize(1024 * 1024))
fmt.Println(util.FormatFileSize(1024 * 1024 * 1024))
fmt.Println(util.FormatFileSize(1024 * 1024 * 1024 * 1024))
fmt.Println(util.FormatFileSize(1024 * 1024 * 1024 * 1024 * 1024))
}
Output: 0B 1B 1.00KB 1.00MB 1.00GB 1.00TB 1.00PB
func FormatFileSizeInt ¶
func NewLogger ¶
Example ¶
// This example demonstrates how to create a new logger with different log levels.
// The logger is configured to write to a file and the log level is set to INFO.
conf := LogConfig{
Filename: "-", // "-" writes to stdout, "" discard logging, otherwise writes to a file
Level: LOG_LEVEL_INFO,
}
logger := NewLogger(conf)
logger.Debug("This is a debug message")
logger.Info("This is an info message")
logger.Warn("This is a warning message")
logger.Error("This is an error message")
Types ¶
Click to show internal directories.
Click to hide internal directories.