mirror of
https://github.com/taigrr/log-socket
synced 2025-01-18 04:53:14 -08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
f51ec53a89
|
|||
|
d21c91379e
|
|||
|
af2116af48
|
|||
|
b65a10e7a8
|
12
.github/FUNDING.yml
vendored
Normal file
12
.github/FUNDING.yml
vendored
Normal 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']
|
||||||
@@ -7,7 +7,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func LogSocketViewHandler(w http.ResponseWriter, r *http.Request) {
|
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"
|
wsResource = strings.TrimSuffix(wsResource, "/") + "/ws"
|
||||||
homeTemplate.Execute(w, wsResource)
|
homeTemplate.Execute(w, wsResource)
|
||||||
}
|
}
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -1,5 +1,5 @@
|
|||||||
module github.com/taigrr/log-socket
|
module github.com/taigrr/log-socket
|
||||||
|
|
||||||
go 1.16
|
go 1.17
|
||||||
|
|
||||||
require github.com/gorilla/websocket v1.4.2
|
require github.com/gorilla/websocket v1.4.2
|
||||||
|
|||||||
@@ -199,6 +199,32 @@ func Infof(format string, args ...interface{}) {
|
|||||||
createLog(e)
|
createLog(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Info prints out logs on info level
|
||||||
|
func Noticef(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
|
// Warn prints out logs on warn level
|
||||||
func Warn(args ...interface{}) {
|
func Warn(args ...interface{}) {
|
||||||
output := fmt.Sprint(args...)
|
output := fmt.Sprint(args...)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ const (
|
|||||||
LTrace Level = iota
|
LTrace Level = iota
|
||||||
LDebug
|
LDebug
|
||||||
LInfo
|
LInfo
|
||||||
|
LNotice
|
||||||
LWarn
|
LWarn
|
||||||
LError
|
LError
|
||||||
LPanic
|
LPanic
|
||||||
|
|||||||
Reference in New Issue
Block a user