Clean up logging and improve web interface

This commit is contained in:
Justin Hawkins 2021-02-07 22:06:19 +10:30
parent 942f81a378
commit 2d1ac3c803
5 changed files with 10 additions and 12 deletions

View File

@ -26,7 +26,9 @@ func LoadOrInit() {
log.Printf("Trying to load from %s\n", configPath)
_, err := os.Stat(configPath)
if os.IsNotExist(err) {
log.Printf("Initialising empty config")
log.Printf("NOTE: No config file, writing out sample configuration")
log.Printf("You need to set the configuration via the web interface")
Config.WebHookURL = ""
Config.Path = homeDir() + string(os.PathSeparator) + "screenshots"
Config.Watch = 10

View File

@ -51,7 +51,7 @@
<form class="">
<div class="form-row align-items-center config-item" data-key="watch">
<div class="col-sm-5 my-1">
<span>Period between filesystem checks</span>
<span>Period between filesystem checks (seconds)</span>
</div>
<div class="col-sm-4 my-1">
<label class="sr-only" for="inlineFormInputName">Seconds</label>
@ -81,9 +81,6 @@
</div>
</form>
<p class="lead">
<a href="#" class="btn btn-lg btn-secondary">Learn more</a>
</p>
</main>

View File

@ -1,8 +1,8 @@
<main role="main" class="inner DAU">
<h1 class="DAU-heading">Discord Auto Upload</h1>
<p class="lead">Hey look it's DAU.</p>
<p class="lead">Hey look, it's DAU :-)</p>
<p class="lead">
<a href="#" class="btn btn-lg btn-secondary">Learn more</a>
<a href="https://github.com/tardisx/discord-auto-upload" class="btn btn-lg btn-secondary">Learn more</a>
</p>
</main>

8
dau.go
View File

@ -55,7 +55,7 @@ func main() {
}
lastCheck = newLastCheck
}
log.Print("sleeping before next check")
log.Printf("sleeping for %ds before next check of %s", config.Config.Watch, config.Config.Path)
time.Sleep(time.Duration(config.Config.Watch) * time.Second)
}
}
@ -63,11 +63,11 @@ func main() {
func checkPath(path string) bool {
src, err := os.Stat(path)
if err != nil {
log.Println("path problem: ", err)
log.Printf("Problem with path '%s': %s", path, err)
return false
}
if !src.IsDir() {
log.Println(path, " is not a directory")
log.Printf("Problem with path '%s': is not a directory", path)
return false
}
return true
@ -287,7 +287,7 @@ func sleepForRetries(retry int) {
}
retryTime := (6-retry)*(6-retry) + 6
log.Printf("Will retry in %d seconds (%d remaining attempts)", retryTime, retry)
// time.Sleep(time.Duration(retryTime) * time.Second)
time.Sleep(time.Duration(retryTime) * time.Second)
}
func newfileUploadRequest(uri string, params map[string]string, paramName, path string) (*http.Request, error) {

View File

@ -206,7 +206,6 @@ func getSetNoWatermark(w http.ResponseWriter, r *http.Request) {
}
func getSetDirectory(w http.ResponseWriter, r *http.Request) {
log.Print("ok")
w.Header().Set("Content-Type", "application/json")
if r.Method == "GET" {