to internal logger for levels, all encompassing path
This commit is contained in:
@@ -7,7 +7,7 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"local/truckstop/config"
|
||||
"log"
|
||||
"local/truckstop/logtr"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -40,7 +40,7 @@ func uploadImage(b []byte) (string, error) {
|
||||
} else if s, ok := u.Query()["name"]; !ok {
|
||||
} else {
|
||||
name = s[0]
|
||||
log.Printf("found name in upload uri: %s", name)
|
||||
logtr.Debugf("found name in upload uri: %s", name)
|
||||
}
|
||||
part, err := writer.CreateFormFile("image", name)
|
||||
if err != nil {
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"local/truckstop/config"
|
||||
"log"
|
||||
"local/truckstop/logtr"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
@@ -45,7 +45,7 @@ func (m Matrix) Continuation() string {
|
||||
|
||||
func (m *Matrix) Receive() ([]Message, error) {
|
||||
if m.mock {
|
||||
log.Printf("matrix.Receive()")
|
||||
logtr.Infof("matrix.Receive()")
|
||||
messages := make([]Message, 0)
|
||||
for k := range config.Get().Clients {
|
||||
messages = append(messages, Message{Timestamp: time.Now(), Sender: k, Content: "!state nc"})
|
||||
@@ -75,10 +75,9 @@ func (m *Matrix) Receive() ([]Message, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Printf("%s => {Start:%s End:%v};; %v, (%d)", m.Continuation(), result.Start, result.End, err, len(result.Chunk))
|
||||
logtr.Debugf("%s => {Start:%s End:%v};; %v, (%d)", m.Continuation(), result.Start, result.End, err, len(result.Chunk))
|
||||
m.continuation = result.End
|
||||
for _, event := range result.Chunk {
|
||||
//log.Printf("%+v", event)
|
||||
if _, ok := matrixIDs[event.Sender]; !ok {
|
||||
continue
|
||||
}
|
||||
@@ -91,7 +90,7 @@ func (m *Matrix) Receive() ([]Message, error) {
|
||||
}
|
||||
}
|
||||
clientChange := regexp.MustCompile("@[a-z]+$")
|
||||
log.Printf("rewriting messages based on @abc")
|
||||
logtr.Debugf("rewriting messages based on @abc")
|
||||
for i := range messages {
|
||||
if found := clientChange.FindString(messages[i].Content); found != "" {
|
||||
messages[i].Content = strings.TrimSpace(strings.ReplaceAll(messages[i].Content, found, ""))
|
||||
@@ -105,7 +104,7 @@ func (m *Matrix) Receive() ([]Message, error) {
|
||||
}
|
||||
messages[i].Content = strings.TrimSpace(messages[i].Content)
|
||||
}
|
||||
log.Printf("rewriting messages based on ! CoMmAnD ...")
|
||||
logtr.Debugf("rewriting messages based on ! CoMmAnD ...")
|
||||
for i := range messages {
|
||||
if strings.HasPrefix(messages[i].Content, "!") {
|
||||
messages[i].Content = "!" + strings.TrimSpace(messages[i].Content[1:])
|
||||
@@ -118,7 +117,7 @@ func (m *Matrix) Receive() ([]Message, error) {
|
||||
|
||||
func (m Matrix) Send(text string) error {
|
||||
if m.mock {
|
||||
log.Printf("matrix.Send(%s)", text)
|
||||
logtr.Infof("matrix.Send(%s)", text)
|
||||
return nil
|
||||
}
|
||||
c, err := m.getclient()
|
||||
@@ -131,7 +130,7 @@ func (m Matrix) Send(text string) error {
|
||||
|
||||
func (m Matrix) SendImage(uri string) error {
|
||||
if m.mock {
|
||||
log.Printf("matrix.SendImage(%s)", uri)
|
||||
logtr.Infof("matrix.SendImage(%s)", uri)
|
||||
return nil
|
||||
}
|
||||
response, err := http.Get(uri)
|
||||
@@ -158,7 +157,7 @@ func (m Matrix) SendImage(uri string) error {
|
||||
}
|
||||
publicURI := mediaUpload.ContentURI
|
||||
resp, err := c.SendImage(m.room, "img", publicURI)
|
||||
log.Printf("sent image %s => %s: %+v", uri, publicURI, resp)
|
||||
logtr.Debugf("sent image %s => %s: %+v", uri, publicURI, resp)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user