Documentation ¶
Index ¶
- Constants
- func Cors(f http.HandlerFunc) http.HandlerFunc
- func CountLines(reader *bufio.Reader) (int, error)
- func GetDurationFromSeconds(seconds float64) string
- func GetRandomDigitString(n int) string
- func GetRandomHexString(n int) string
- func GetRandomUUIDString() string
- func GetStorageSize(num interface{}) string
- func HTTPDigest(method string, uri string, username string, password string, ...) (*http.Response, error)
- func MilliToTimeString(milli float64) string
- func NewFileReader(filename string) (*bufio.Reader, error)
- func NewReader(file *os.File) (*bufio.Reader, error)
- func OutputGzipped(b []byte, filename string) error
- func ReadAll(file *os.File) ([]byte, error)
- func StartWebServer(port int) error
- func Stringify(doc interface{}, opts ...string) string
- func ToFloat64(num interface{}) (float64, error)
- func ToInt64(num interface{}) (int64, error)
- func ZipFiles(zipFilename string, filenames []string) error
- type Logger
- func (p *Logger) Debug(v ...interface{})
- func (p *Logger) Debugf(format string, v ...interface{})
- func (p *Logger) Error(v ...interface{})
- func (p *Logger) Errorf(format string, v ...interface{})
- func (p *Logger) Info(v ...interface{})
- func (p *Logger) Infof(format string, v ...interface{})
- func (p *Logger) Print() string
- func (p *Logger) Remark(v ...interface{})
- func (p *Logger) Remarkf(format string, v ...interface{})
- func (p *Logger) SetLoggerLevel(level int)
- func (p *Logger) Trace(v ...interface{})
- func (p *Logger) Tracef(format string, v ...interface{})
- func (p *Logger) Warn(v ...interface{})
- func (p *Logger) Warnf(format string, v ...interface{})
- type MapWalker
- type MongoLog
- type OrderedMap
- type WaitGroup
Constants ¶
const ( Trace int = iota Debug Info Remark Warn Error )
specify logger level
Variables ¶
This section is empty.
Functions ¶
func CountLines ¶
CountLines count number of '\n'
func GetDurationFromSeconds ¶
GetDurationFromSeconds converts seconds to time string, e.g. 1.5m
func GetRandomDigitString ¶
GetRandomDigitString returns a random digit string
func GetRandomHexString ¶
GetRandomHexString returns a random hex string
func GetRandomUUIDString ¶
func GetRandomUUIDString() string
GetRandomUUIDString returns a random UUID string
func GetStorageSize ¶
func GetStorageSize(num interface{}) string
GetStorageSize returns storage size in [TGMK] B
func HTTPDigest ¶
func HTTPDigest(method string, uri string, username string, password string, headers map[string]string, body ...[]byte) (*http.Response, error)
HTTPDigest --digest
func MilliToTimeString ¶
MilliToTimeString converts milliseconds to time string, e.g. 1.5m
func NewFileReader ¶
NewFileReader returns a reader from either a gzip or plain file
func OutputGzipped ¶
OutputGzipped writes doc to a gzipped file
Types ¶
type Logger ¶
type Logger struct { AppName string `json:"version" bson:"version"` Logs []string `json:"logs" bson:"logs"` // contains filtered or unexported fields }
Logger stores logger info
func (*Logger) Error ¶
func (p *Logger) Error(v ...interface{})
Error adds and prints an error message
func (*Logger) Remark ¶ added in v0.2.2
func (p *Logger) Remark(v ...interface{})
Remark adds and prints a message
func (*Logger) SetLoggerLevel ¶
SetLoggerLevel sets logger level
type MapWalker ¶
type MapWalker struct {
// contains filtered or unexported fields
}
MapWalker is an empty JSON document
func (*MapWalker) GetMaxArrayLength ¶
GetMaxArrayLength return the max array length
func (*MapWalker) GetNestedLevel ¶
GetNestedLevel return the level of nested document
func (*MapWalker) SetCallBack ¶
func (walker *MapWalker) SetCallBack(cb callback)
SetCallBack defines callback function
type MongoLog ¶
type MongoLog struct {
// contains filtered or unexported fields
}
MongoLog stores a line of mongo log
type OrderedMap ¶
OrderedMap preserves keys order
func NewOrderedMap ¶
func NewOrderedMap(str string) *OrderedMap
NewOrderedMap returns an ordered map
func (OrderedMap) MarshalJSON ¶
func (om OrderedMap) MarshalJSON() ([]byte, error)
MarshalJSON is used by json.Marshal
func (*OrderedMap) UnmarshalJSON ¶
func (om *OrderedMap) UnmarshalJSON(b []byte) error
UnmarshalJSON is used by json.Unmarshal