1
1
Fork 0

making unnecessary commits for pretty stdout

This commit is contained in:
kayos@tcp.direct 2021-01-31 09:26:50 -08:00
parent 5595ec9404
commit 324fcd6789
5 changed files with 19 additions and 21 deletions

View File

@ -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()")
}

View File

@ -1,7 +1,7 @@
title = "tcp.ac config"
[global]
debug = false
debug = true
[http]
baseurl = "http://127.0.0.1:8080/"

16
db.go
View File

@ -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")
}

View File

@ -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}

View File

@ -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)
}