1
0
mirror of https://github.com/taigrr/log-socket synced 2025-01-18 04:53:14 -08:00

6 Commits

Author SHA1 Message Date
c18854598d Added a logger type 2021-08-23 21:25:01 -07:00
63ed3a2ad7 logger => log 2021-08-23 21:12:21 -07:00
f51ec53a89 Adds Notice logging level to support NATS 2021-08-23 20:58:15 -07:00
d21c91379e update go compiler target version 2021-08-17 10:07:07 -07:00
af2116af48 add sponsorship 2021-07-05 21:03:17 -07:00
b65a10e7a8 detect tls presence based on incoming request for websocket 2021-07-05 16:10:50 -07:00
9 changed files with 118 additions and 7 deletions

12
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
# These are supported funding model platforms
github: taigrr # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

View File

@@ -7,7 +7,12 @@ import (
)
func LogSocketViewHandler(w http.ResponseWriter, r *http.Request) {
wsResource := "ws://" + r.Host + r.URL.Path
wsResource := r.Host + r.URL.Path
if r.TLS != nil {
wsResource = "wss://" + wsResource
} else {
wsResource = "ws://" + wsResource
}
wsResource = strings.TrimSuffix(wsResource, "/") + "/ws"
homeTemplate.Execute(w, wsResource)
}

2
go.mod
View File

@@ -1,5 +1,5 @@
module github.com/taigrr/log-socket
go 1.16
go 1.17
require github.com/gorilla/websocket v1.4.2

View File

@@ -1,4 +1,4 @@
package logger
package log
import (
"errors"
@@ -199,6 +199,32 @@ func Infof(format string, args ...interface{}) {
createLog(e)
}
// Info prints out logs on info level
func Notice(args ...interface{}) {
output := fmt.Sprint(args...)
e := Entry{
Timestamp: time.Now(),
Output: output,
File: fileInfo(2),
Level: "NOTICE",
level: LNotice,
}
createLog(e)
}
// Formatted print for Info
func Noticef(format string, args ...interface{}) {
output := fmt.Sprintf(format, args...)
e := Entry{
Timestamp: time.Now(),
Output: output,
File: fileInfo(2),
Level: "NOTICE",
level: LNotice,
}
createLog(e)
}
// Warn prints out logs on warn level
func Warn(args ...interface{}) {
output := fmt.Sprint(args...)

View File

@@ -1,4 +1,4 @@
package logger
package log
import (
"strconv"

64
log/logger.go Normal file
View File

@@ -0,0 +1,64 @@
package log
func (_ Logger) Trace(args ...interface{}) {
Trace(args...)
}
func (_ Logger) Tracef(format string, args ...interface{}) {
Tracef(format, args...)
}
func (_ Logger) Debug(args ...interface{}) {
Debug(args...)
}
func (_ Logger) Debugf(format string, args ...interface{}) {
Debugf(format, args...)
}
func (_ Logger) Info(args ...interface{}) {
Info(args...)
}
func (_ Logger) Infof(format string, args ...interface{}) {
Infof(format, args...)
}
func (_ Logger) Notice(args ...interface{}) {
Notice(args...)
}
func (_ Logger) Noticef(format string, args ...interface{}) {
Noticef(format, args...)
}
func (_ Logger) Warn(args ...interface{}) {
Warn(args...)
}
func (_ Logger) Warnf(format string, args ...interface{}) {
Warnf(format, args...)
}
func (_ Logger) Error(args ...interface{}) {
Error(args...)
}
func (_ Logger) Errorf(format string, args ...interface{}) {
Errorf(format, args...)
}
func (_ Logger) Panic(args ...interface{}) {
Panic(args...)
}
func (_ Logger) Panicf(format string, args ...interface{}) {
Panicf(format, args...)
}
func (_ Logger) Fatal(args ...interface{}) {
Fatal(args...)
}
func (_ Logger) Fatalf(format string, args ...interface{}) {
Fatalf(format, args...)
}

View File

@@ -1,4 +1,4 @@
package logger
package log
import "time"
@@ -9,6 +9,7 @@ const (
LTrace Level = iota
LDebug
LInfo
LNotice
LWarn
LError
LPanic
@@ -28,3 +29,6 @@ type Entry struct {
Level string `json:"level"`
level Level
}
type Logger struct {
}

View File

@@ -6,7 +6,7 @@ import (
"time"
"github.com/taigrr/log-socket/browser"
"github.com/taigrr/log-socket/logger"
logger "github.com/taigrr/log-socket/log"
"github.com/taigrr/log-socket/ws"
)

View File

@@ -5,7 +5,7 @@ import (
"net/http"
"github.com/gorilla/websocket"
"github.com/taigrr/log-socket/logger"
logger "github.com/taigrr/log-socket/log"
)
// var addr = flag.String("addr", "localhost:8080", "http service address")