summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md16
-rw-r--r--reallog.go24
2 files changed, 27 insertions, 13 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..0de5e9b
--- /dev/null
+++ b/README.md
@@ -0,0 +1,16 @@
+log
+
+This is an attempt to modify the default golang 'log'.
+Because the 'gui' toolkit could be either ncurses or something like gtk,
+'log' is an attempt to be smart about changing STDOUT on the fly.
+
+* add meaningful shortcuts like log.Info(), log.Warn(), log.Error() etc
+* add flags to enable & disable output on a per-gomodule basis
+* add http flag to switch stdout to http socket
+* compatible with changing import 'log' to import 'go.wit.com/log'
+* should also be compatible with changing import 'fmt' to import fmt 'go.wit.com/log'
+
+Notes & Goals:
+
+* be a complete droplet replacement for golang 'log'
+* provide an example of how the stdlib 'log' could be changed
diff --git a/reallog.go b/reallog.go
index a2c9a76..3629639 100644
--- a/reallog.go
+++ b/reallog.go
@@ -26,25 +26,23 @@ func DaemonShow() {
}
func realPrintln(a ...any) {
- if httpMode == nil {
- if daemonMode {
- fmt.Println(a...)
- } else {
- reallog.Println(a...)
- }
+ if daemonMode {
+ fmt.Println(a...)
} else {
- fmt.Fprintln(httpMode, a...)
+ reallog.Println(a...)
+ }
+ if httpMode != nil {
+ fmt.Fprintln(httpMode, fmt.Sprint(a...))
}
}
func realPrintf(s string, a ...any) {
- if httpMode == nil {
- if daemonMode {
- fmt.Printf(s, a...)
- } else {
- reallog.Printf(s, a...)
- }
+ if daemonMode {
+ fmt.Printf(s, a...)
} else {
+ reallog.Printf(s, a...)
+ }
+ if httpMode != nil {
fmt.Fprintln(httpMode, fmt.Sprintf(s, a...))
}
}