mirror of
https://github.com/Luzifer/cloudkeys-go.git
synced 2024-11-15 01:12:44 +00:00
9c6e3c89a5
* fix js scoping issue * add external libraries (they were offline too often) * new compiled scripts and css * new fixes in the binary * vendor update * change js source * remove needless variable * removed more needless variables
54 lines
1 KiB
Go
54 lines
1 KiB
Go
// +build codegen
|
|
|
|
package api
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"sync"
|
|
)
|
|
|
|
var debugLogger *logger
|
|
var initDebugLoggerOnce sync.Once
|
|
|
|
// logger provides a basic logging
|
|
type logger struct {
|
|
w io.Writer
|
|
}
|
|
|
|
// LogDebug initialize's the debug logger for the components in the api
|
|
// package to log debug lines to.
|
|
//
|
|
// Panics if called multiple times.
|
|
//
|
|
// Must be used prior to any model loading or code gen.
|
|
func LogDebug(w io.Writer) {
|
|
var initialized bool
|
|
initDebugLoggerOnce.Do(func() {
|
|
debugLogger = &logger{
|
|
w: w,
|
|
}
|
|
initialized = true
|
|
})
|
|
|
|
if !initialized && debugLogger != nil {
|
|
panic("LogDebug called multiple times. Can only be called once")
|
|
}
|
|
}
|
|
|
|
// Logf logs using the fmt printf pattern. Appends a new line to the end of the
|
|
// logged statement.
|
|
func (l *logger) Logf(format string, args ...interface{}) {
|
|
if l == nil {
|
|
return
|
|
}
|
|
fmt.Fprintf(l.w, format+"\n", args...)
|
|
}
|
|
|
|
// Logln logs using the fmt println pattern.
|
|
func (l *logger) Logln(args ...interface{}) {
|
|
if l == nil {
|
|
return
|
|
}
|
|
fmt.Fprintln(l.w, args...)
|
|
}
|