refactor: replace log statements with fmt for console output
All checks were successful
Release / Build versioned release (push) Successful in 16s
All checks were successful
Release / Build versioned release (push) Successful in 16s
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package steamcache
|
||||
|
||||
import (
|
||||
"log"
|
||||
"fmt"
|
||||
"s1d3sw1ped/SteamCache2/vfs"
|
||||
"s1d3sw1ped/SteamCache2/vfs/cachestate"
|
||||
"time"
|
||||
@@ -17,7 +17,7 @@ func randomgc(vfss vfs.VFS, stats []*vfs.FileInfo) int64 {
|
||||
err := vfss.Delete(randfile.Name())
|
||||
if err != nil {
|
||||
// If we failed to delete the file, log it and return 0
|
||||
// log.Printf("Failed to delete %s: %v", randfile.Name(), err)
|
||||
// fmt.Printf("Failed to delete %s: %v", randfile.Name(), err)
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ func memorygc(vfss vfs.VFS, size int) {
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("GC of %s took %v to reclaim %s by deleting %d files", vfss.Name(), time.Since(tstart), units.HumanSize(float64(reclaimed)), deletions)
|
||||
fmt.Printf("GC of %s took %v to reclaim %s by deleting %d files", vfss.Name(), time.Since(tstart), units.HumanSize(float64(reclaimed)), deletions)
|
||||
}
|
||||
|
||||
func diskgc(vfss vfs.VFS, size int) {
|
||||
@@ -57,7 +57,7 @@ func diskgc(vfss vfs.VFS, size int) {
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("GC of %s took %v to reclaim %s by deleting %d files", vfss.Name(), time.Since(tstart), units.HumanSize(float64(reclaimed)), deletions)
|
||||
fmt.Printf("GC of %s took %v to reclaim %s by deleting %d files", vfss.Name(), time.Since(tstart), units.HumanSize(float64(reclaimed)), deletions)
|
||||
}
|
||||
|
||||
func cachehandler(fi *vfs.FileInfo, cs cachestate.CacheState) bool {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package steamcache
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"s1d3sw1ped/SteamCache2/steamcache/avgcachestate"
|
||||
"s1d3sw1ped/SteamCache2/vfs"
|
||||
"s1d3sw1ped/SteamCache2/vfs/cache"
|
||||
@@ -79,7 +80,7 @@ func New(address string, memorySize string, memoryMultiplier int, diskSize strin
|
||||
}
|
||||
|
||||
func (sc *SteamCache) Run() {
|
||||
log.Printf("SteamCache2 running on %s", sc.address)
|
||||
fmt.Printf("SteamCache2 running on %s", sc.address)
|
||||
|
||||
sc.mu.Lock()
|
||||
sc.dirty = true
|
||||
@@ -95,7 +96,8 @@ func (sc *SteamCache) Run() {
|
||||
|
||||
err := http.ListenAndServe(sc.address, sc)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,8 +105,8 @@ func (sc *SteamCache) LogStats() {
|
||||
sc.mu.Lock()
|
||||
defer sc.mu.Unlock()
|
||||
if sc.dirty {
|
||||
log.Printf(
|
||||
"SteamCache2 %s: (%d) %s/%s %s: (%d) %s/%s Hitrate: %f%%",
|
||||
fmt.Printf(
|
||||
"%s: (%d) %s/%s %s: (%d) %s/%s Hitrate: %f%%",
|
||||
sc.memory.Name(), len(sc.memory.StatAll()), units.HumanSize(float64(sc.memory.Size())), units.HumanSize(float64(sc.memory.Capacity())),
|
||||
sc.disk.Name(), len(sc.disk.StatAll()), units.HumanSize(float64(sc.disk.Size())), units.HumanSize(float64(sc.disk.Capacity())),
|
||||
sc.hits.Avg()*100,
|
||||
@@ -139,7 +141,7 @@ func (sc *SteamCache) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// tstart := time.Now()
|
||||
// defer func() {
|
||||
// log.Printf("%s %s %s took %s", r.Method, r.URL.String(), w.Header().Get("X-LanCache-Status"), time.Since(tstart))
|
||||
// fmt.Printf("%s %s %s took %s", r.Method, r.URL.String(), w.Header().Get("X-LanCache-Status"), time.Since(tstart))
|
||||
// }()
|
||||
|
||||
sc.mu.Lock()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package disk
|
||||
|
||||
import (
|
||||
"log"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"s1d3sw1ped/SteamCache2/vfs"
|
||||
@@ -53,14 +53,14 @@ func NewSkipInit(root string, capacity int64) *DiskFS {
|
||||
}
|
||||
|
||||
func (d *DiskFS) init() {
|
||||
// log.Printf("DiskFS(%s, %s) init", d.root, units.HumanSize(float64(d.capacity)))
|
||||
// fmt.Printf("DiskFS(%s, %s) init", d.root, units.HumanSize(float64(d.capacity)))
|
||||
|
||||
tstart := time.Now()
|
||||
|
||||
d.walk(d.root)
|
||||
d.sg.Wait()
|
||||
|
||||
log.Printf("DiskFS(%s, %s) init took %v", d.root, units.HumanSize(float64(d.capacity)), time.Since(tstart))
|
||||
fmt.Printf("DiskFS(%s, %s) init took %v", d.root, units.HumanSize(float64(d.capacity)), time.Since(tstart))
|
||||
}
|
||||
|
||||
func (d *DiskFS) walk(path string) {
|
||||
@@ -86,7 +86,7 @@ func (d *DiskFS) walk(path string) {
|
||||
d.info[k] = vfs.NewFileInfoFromOS(info, k)
|
||||
d.mu.Unlock()
|
||||
|
||||
// log.Printf("DiskFS(%s, %s) init: %s", d.root, units.HumanSize(float64(d.capacity)), npath)
|
||||
// fmt.Printf("DiskFS(%s, %s) init: %s", d.root, units.HumanSize(float64(d.capacity)), npath)
|
||||
return nil
|
||||
})
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user