From 324fcd6789802190451de4f2db1fae250d59b870 Mon Sep 17 00:00:00 2001 From: "kayos@tcp.direct" Date: Sun, 31 Jan 2021 09:26:50 -0800 Subject: [PATCH] making unnecessary commits for pretty stdout --- config.go | 14 +++++++------- config.toml | 2 +- db.go | 16 ++++++++-------- main.go | 7 ++----- router.go | 1 + 5 files changed, 19 insertions(+), 21 deletions(-) diff --git a/config.go b/config.go index 3af1cec..cc91292 100644 --- a/config.go +++ b/config.go @@ -33,30 +33,30 @@ func configRead() { s = "http.baseurl" baseUrl = viper.GetString(s) - log.Debug().Str(s, baseUrl).Msg("[config]") + log.Debug().Str(s, baseUrl).Msg("configRead()") s = "http.port" i := viper.GetInt(s) webPort = strconv.Itoa(i) // int looks cleaner in config - log.Debug().Str(s, webPort).Msg("[config]") // but we reference it as a string later + log.Debug().Str(s, webPort).Msg("configRead()") // but we reference it as a string later s = "http.bindip" webIP = viper.GetString(s) - log.Debug().Str(s, webIP).Msg("[config]") + log.Debug().Str(s, webIP).Msg("configRead()") s = "files.data" dbDir = viper.GetString(s) - log.Debug().Str(s, dbDir).Msg("[config]") // where we're actually gonna store everything + log.Debug().Str(s, dbDir).Msg("configRead()") // where we're actually gonna store everything s = "files.logs" logDir = viper.GetString(s) - log.Debug().Str(s, logDir).Msg("[config]") + log.Debug().Str(s, logDir).Msg("configRead()") s = "img.uidsize" uidSize = viper.GetInt(s) - log.Debug().Int(s, uidSize).Msg("[config]") + log.Debug().Int(s, uidSize).Msg("configRead()") s = "img.delkeysize" keySize = viper.GetInt(s) - log.Debug().Int(s, keySize).Msg("[config]") + log.Debug().Int(s, keySize).Msg("configRead()") } diff --git a/config.toml b/config.toml index 6c15ef7..f603009 100644 --- a/config.toml +++ b/config.toml @@ -1,7 +1,7 @@ title = "tcp.ac config" [global] -debug = false +debug = true [http] baseurl = "http://127.0.0.1:8080/" diff --git a/db.go b/db.go index 9d1ff88..26886a4 100644 --- a/db.go +++ b/db.go @@ -1,8 +1,8 @@ package main import ( - "fmt" "github.com/prologic/bitcask" + "github.com/rs/zerolog/log" ) func dbInit() { @@ -10,18 +10,18 @@ func dbInit() { bitcask.WithMaxValueSize(24 / 1024 / 1024), } + hashDB, _ = bitcask.Open(dbDir+"hsh", opts...) // this will probably only be for images? + log.Debug().Msg("Initializing checksum database") + keyDB, _ = bitcask.Open(dbDir+"key", opts...) // delete keys (maybe for all objects?) - fmt.Println("Initializing key database") + log.Debug().Msg("Initializing key database") imgDB, _ = bitcask.Open(dbDir+"img", opts...) // literal image files - fmt.Println("Initializing img database") - - hashDB, _ = bitcask.Open(dbDir+"hsh", opts...) // this will probably only be for images? - fmt.Println("Initializing checksum database") + log.Debug().Msg("Initializing img database") txtDB, _ = bitcask.Open(dbDir + "txt") // pastebin - fmt.Println("Initializing txt database") + log.Debug().Msg("Initializing txt database") urlDB, _ = bitcask.Open(dbDir + "url") // url shortener entries - fmt.Println("Initializing url database") + log.Debug().Msg("Initializing url database") } diff --git a/main.go b/main.go index 639c152..b060fb7 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,6 @@ package main import ( "github.com/rs/zerolog/log" "github.com/rs/zerolog" - "fmt" "os" ) @@ -11,13 +10,11 @@ func init() { // initialize the logger before the config: that way we can output debug lines // pertaining to the parsing of the configuration init - fmt.Println("Initializing...") - //////////// init logging //////////// log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}) // before we read config, do Stderr pretty print (need logs location) - log.Info().Msg("Reading configuration file...") + log.Info().Msg("Initializing...") // see config.go configRead() @@ -38,7 +35,7 @@ func init() { lf, err := os.OpenFile(logDir+"tcpac.log", os.O_RDWR | os.O_CREATE | os.O_APPEND, 0666) if err != nil { - fmt.Println("Error opening log file: " + err.Error()) + log.Fatal().Str("logDir",logDir).Err(err).Msg("Error opening log file!") } consoleWriter := zerolog.ConsoleWriter{Out: os.Stdout} diff --git a/router.go b/router.go index d22984b..1c1ef8b 100644 --- a/router.go +++ b/router.go @@ -34,6 +34,7 @@ func httpRouter() { imgR := router.Group("/i") { + imgR.GET("/", func(c *gin.Context) { c.String(200,"") }) // javascript wants something here idk imgR.POST("/put", imgPost) // put looks nicer even though its actually POST imgR.GET("/:uid", imgView) }