Compare commits
No commits in common. "master" and "v0.22.14" have entirely different histories.
2
Makefile
2
Makefile
|
@ -1,6 +1,6 @@
|
||||||
# git remote add github git@github.com:wit-go/log.git
|
# git remote add github git@github.com:wit-go/log.git
|
||||||
|
|
||||||
all: goimport vet
|
all: vet
|
||||||
@#GO111MODULE=off go vet -x
|
@#GO111MODULE=off go vet -x
|
||||||
@echo this go library builds ok
|
@echo this go library builds ok
|
||||||
|
|
||||||
|
|
6
error.go
6
error.go
|
@ -4,8 +4,6 @@
|
||||||
|
|
||||||
package log
|
package log
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
func Error(err error, a ...any) {
|
func Error(err error, a ...any) {
|
||||||
if ERROR.Disabled() {
|
if ERROR.Disabled() {
|
||||||
return
|
return
|
||||||
|
@ -13,7 +11,3 @@ func Error(err error, a ...any) {
|
||||||
realPrintln("Error:", err)
|
realPrintln("Error:", err)
|
||||||
realPrintln(a...)
|
realPrintln(a...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Errorf(f string, a ...any) error {
|
|
||||||
return fmt.Errorf(f, a...)
|
|
||||||
}
|
|
||||||
|
|
4
flags.go
4
flags.go
|
@ -30,8 +30,6 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
var off bool // completely shut up until I tell you to talk again
|
|
||||||
|
|
||||||
var INFO *LogFlag // toggles log.Info()
|
var INFO *LogFlag // toggles log.Info()
|
||||||
var VERBOSE *LogFlag // toggles log.Verbose()
|
var VERBOSE *LogFlag // toggles log.Verbose()
|
||||||
var SPEW *LogFlag // toggles log.Spew()
|
var SPEW *LogFlag // toggles log.Spew()
|
||||||
|
@ -150,7 +148,7 @@ func (f *LogFlag) Disabled() bool {
|
||||||
if !f.Ok() {
|
if !f.Ok() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return !f.b
|
return ! f.b
|
||||||
}
|
}
|
||||||
|
|
||||||
// just the opposite of Disabled()
|
// just the opposite of Disabled()
|
||||||
|
|
10
original.go
10
original.go
|
@ -1,7 +1,5 @@
|
||||||
package log
|
package log
|
||||||
|
|
||||||
import "io"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
@ -83,14 +81,6 @@ func Sprintln(a ...any) string {
|
||||||
return realSprintln(a...)
|
return realSprintln(a...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Fprintln(w io.Writer, a ...any) (int, error) {
|
|
||||||
return realFprintln(w, a...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Fprintf(w io.Writer, s string, a ...any) (int, error) {
|
|
||||||
return realFprintf(w, s, a...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Fatalln(a ...any) {
|
func Fatalln(a ...any) {
|
||||||
realFatalln(a...)
|
realFatalln(a...)
|
||||||
}
|
}
|
||||||
|
|
33
reallog.go
33
reallog.go
|
@ -11,14 +11,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Off() {
|
|
||||||
off = true
|
|
||||||
}
|
|
||||||
|
|
||||||
func On() {
|
|
||||||
off = false
|
|
||||||
}
|
|
||||||
|
|
||||||
func DaemonMode(b bool) {
|
func DaemonMode(b bool) {
|
||||||
daemonMode = b
|
daemonMode = b
|
||||||
}
|
}
|
||||||
|
@ -27,6 +19,7 @@ func Timestamps(b bool) {
|
||||||
timestamps = b
|
timestamps = b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var captureMode io.Writer
|
var captureMode io.Writer
|
||||||
|
|
||||||
func CaptureMode(w io.Writer) {
|
func CaptureMode(w io.Writer) {
|
||||||
|
@ -61,9 +54,6 @@ func DaemonShow() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func realPrintln(a ...any) {
|
func realPrintln(a ...any) {
|
||||||
if off {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if daemonMode {
|
if daemonMode {
|
||||||
// in daemon mode, don't put timestamps on each line
|
// in daemon mode, don't put timestamps on each line
|
||||||
if captureMode == nil {
|
if captureMode == nil {
|
||||||
|
@ -74,11 +64,11 @@ func realPrintln(a ...any) {
|
||||||
} else {
|
} else {
|
||||||
// put timestamps on each line
|
// put timestamps on each line
|
||||||
if captureMode == nil {
|
if captureMode == nil {
|
||||||
if timestamps {
|
if timestamps {
|
||||||
reallog.Println(a...)
|
reallog.Println(a...)
|
||||||
} else {
|
} else {
|
||||||
fmt.Println(a...)
|
fmt.Println(a...)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// TODO: add datestamp
|
// TODO: add datestamp
|
||||||
fmt.Fprintln(captureMode, a...)
|
fmt.Fprintln(captureMode, a...)
|
||||||
|
@ -99,9 +89,6 @@ func realPrintln(a ...any) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func realPrintf(s string, a ...any) {
|
func realPrintf(s string, a ...any) {
|
||||||
if off {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if daemonMode {
|
if daemonMode {
|
||||||
// in daemon mode, don't put timestamps on each line
|
// in daemon mode, don't put timestamps on each line
|
||||||
if captureMode == nil {
|
if captureMode == nil {
|
||||||
|
@ -147,14 +134,6 @@ func realSprintln(a ...any) string {
|
||||||
return fmt.Sprintln(a...)
|
return fmt.Sprintln(a...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func realFprintln(w io.Writer, a ...any) (int, error) {
|
|
||||||
return fmt.Fprintln(w, a...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func realFprintf(w io.Writer, s string, a ...any) (int, error) {
|
|
||||||
return fmt.Fprintf(w, s, a...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func realFatalln(a ...any) {
|
func realFatalln(a ...any) {
|
||||||
reallog.Fatalln(a...)
|
reallog.Fatalln(a...)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue