381fb85b1d
* add send notify function * add shell script * add system notiry * remove disk and test common package * update http status * add share function to common * remove temp path * remove /DATA directory initialization - moved to local-storage (#578) * update goreleaser configuration * wip * change service type to notify for systemd so its status is OK only when service is initialized successfully * update CasaOS-Common to fix runtime error * wip * add send notify function * add shell script * add system notiry * remove disk and test common package * update http status * add share function to common * remove temp path * remove /DATA directory initialization - moved to local-storage (#578) * update goreleaser configuration * wip * change service type to notify for systemd so its status is OK only when service is initialized successfully * update CasaOS-Common to fix runtime error * wip * wip * wip * wip * wip * Utilization interface to supplement disk information * fix upload file * wip * wip * add update url * wip * wip * add change log * update changelog Co-authored-by: LinkLeong <a624669980@163.com>
37 lines
639 B
Go
37 lines
639 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
)
|
|
|
|
type Logger struct {
|
|
DebugMode bool
|
|
|
|
_debug *log.Logger
|
|
_info *log.Logger
|
|
_error *log.Logger
|
|
}
|
|
|
|
func NewLogger() *Logger {
|
|
return &Logger{
|
|
DebugMode: false,
|
|
_debug: log.New(os.Stdout, "DEBUG: ", 0),
|
|
_info: log.New(os.Stdout, "", 0),
|
|
_error: log.New(os.Stderr, "ERROR: ", 0),
|
|
}
|
|
}
|
|
|
|
func (l *Logger) Debug(format string, v ...interface{}) {
|
|
if l.DebugMode {
|
|
l._debug.Printf(format, v...)
|
|
}
|
|
}
|
|
|
|
func (l *Logger) Info(format string, v ...interface{}) {
|
|
l._info.Printf(format, v...)
|
|
}
|
|
|
|
func (l *Logger) Error(format string, v ...interface{}) {
|
|
l._error.Printf(format, v...)
|
|
}
|