Compare commits
No commits in common. "aeb198e3c1705a832272171bd21e033cb7179213" and "3b3f68c525c850dfc330206ef15bb77b7db2f29f" have entirely different histories.
aeb198e3c1
...
3b3f68c525
|
@ -1,2 +0,0 @@
|
||||||
*.swp
|
|
||||||
httptail
|
|
14
main.go
14
main.go
|
@ -27,14 +27,15 @@ func fileHandler(w http.ResponseWriter, r *http.Request, s string) {
|
||||||
sendFile(w, fn, "", "No such file or directory")
|
sendFile(w, fn, "", "No such file or directory")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Println("watch: %#v", watch)
|
|
||||||
if (watch == false) {
|
if (watch == false) {
|
||||||
t, err := tail.TailFile(fn, tail.Config{Follow: false, MustExist: true})
|
t, err := tail.TailFile(fn, tail.Config{Follow: false})
|
||||||
watch = true
|
watch = true
|
||||||
|
}
|
||||||
|
|
||||||
if (err == nil) {
|
if (err == nil) {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
var m = ""
|
var m = ""
|
||||||
|
|
||||||
|
@ -51,10 +52,10 @@ func fileHandler(w http.ResponseWriter, r *http.Request, s string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func sendFile(w http.ResponseWriter, fn string, m string, err string) {
|
func sendFile(w http.ResponseWriter, fn string, m string, err string) {
|
||||||
json.NewEncoder(w).Encode(map[string]string{"time": strconv.FormatInt(getMsTimestamp(), 16), "Filename": fn, "Text": m, "error": err})
|
json.NewEncoder(w).Encode(map[string]string{"time": strconv.FormatInt(t_ms(), 16), "Filename": fn, "Text": m, "error": err})
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMsTimestamp() (int64) {
|
func t_ms() (int64) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
ns := now.UnixNano()
|
ns := now.UnixNano()
|
||||||
ms := ns / 1000000
|
ms := ns / 1000000
|
||||||
|
@ -87,6 +88,7 @@ var m_prev = ""
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
uid := os.Getuid()
|
uid := os.Getuid()
|
||||||
|
t.Filename = ""
|
||||||
|
|
||||||
if (uid == -1) {
|
if (uid == -1) {
|
||||||
fmt.Println("Windows is unsupported")
|
fmt.Println("Windows is unsupported")
|
||||||
|
@ -101,5 +103,5 @@ func main() {
|
||||||
|
|
||||||
fmt.Println("Serving " + prj + " " + version + " on " + server_inet6)
|
fmt.Println("Serving " + prj + " " + version + " on " + server_inet6)
|
||||||
http.ListenAndServe(server_inet6, nil)
|
http.ListenAndServe(server_inet6, nil)
|
||||||
//t.Cleanup()
|
t.Cleanup()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue