Skip to content

Commit

Permalink
trace level is very verbose now
Browse files Browse the repository at this point in the history
  • Loading branch information
kovetskiy committed Nov 3, 2020
1 parent b33512b commit ec4b258
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 151 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/mark
/docker
/testdata
10 changes: 4 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@ go 1.14

require (
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/bndr/gopencils v0.0.0-20161113114152-22e283ad7611
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
github.com/go-yaml/yaml v2.1.0+incompatible // indirect
github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334 // indirect
github.com/kovetskiy/godocs v0.0.0-20160817104724-2d9428f80f34
github.com/kovetskiy/gopencils v0.0.0-20201103141120-610929377f9b
github.com/kovetskiy/ko v0.0.0-20190324102900-26b8dd0988bf
github.com/kovetskiy/lorg v0.0.0-20180412114932-05d42d7f98ba
github.com/kovetskiy/lorg v0.0.0-20200107130803-9a7136a95634
github.com/kovetskiy/toml v0.2.0 // indirect
github.com/reconquest/cog v0.0.0-20190411204516-c6b6b90dcd40
github.com/reconquest/karma-go v0.0.0-20190930125156-7b5c19ad6eab
github.com/reconquest/karma-go v0.0.0-20200326104714-79480464fdb5
github.com/reconquest/pkg v0.0.0-20201028091908-8e9a5e0226ef
github.com/reconquest/regexputil-go v0.0.0-20160905154124-38573e70c1f4
github.com/russross/blackfriday v1.5.2
github.com/stretchr/testify v1.5.1 // indirect
github.com/zazab/zhash v0.0.0-20170403032415-ad45b89afe7a // indirect
gopkg.in/yaml.v2 v2.2.8
)
37 changes: 27 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,38 +1,55 @@
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/bndr/gopencils v0.0.0-20161113114152-22e283ad7611 h1:hqtAgYVdJDEoCOqABNtiNgVlGFXmn5zN0i7h7a/mh68=
github.com/bndr/gopencils v0.0.0-20161113114152-22e283ad7611/go.mod h1:h/74eddHMsY5P4bCkKTVWWZ+J6nsKMNvDEetFHG7PIY=
github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 h1:bWDMxwH3px2JBh6AyO7hdCn/PkvCZXii8TGj7sbtEbQ=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM=
github.com/go-chi/chi v4.1.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
github.com/go-yaml/yaml v2.1.0+incompatible h1:RYi2hDdss1u4YE7GwixGzWwVo47T8UQwnTLB6vQiq+o=
github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaLENm+P+Tv+MfurjSw0=
github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334 h1:VHgatEHNcBFEB7inlalqfNqw65aNkM1lGX2yt3NmbS8=
github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE=
github.com/kovetskiy/godocs v0.0.0-20160817104724-2d9428f80f34 h1:bUWVdQQT5QLGFudBaGJE9v3Zf0EdDiDd5h8vAj9sMVg=
github.com/kovetskiy/godocs v0.0.0-20160817104724-2d9428f80f34/go.mod h1:u+dvDLWaaxNkHMvhUK1IBXTNS3fhDvdy3BqQrZM8w/k=
github.com/kovetskiy/gopencils v0.0.0-20201103141120-610929377f9b h1:+PnJcuiUVcU3ixOvpvhyjswKPkxBVN+a2CaFCNNBfvw=
github.com/kovetskiy/gopencils v0.0.0-20201103141120-610929377f9b/go.mod h1:rn9YsgK4kxBDPZn+hOwSmg6MdtWfF2ejC3tvgDjWyBM=
github.com/kovetskiy/ko v0.0.0-20190324102900-26b8dd0988bf h1:4QsqgCcPoqDB91dcp4GffoV6TjwfVURaWpjKWFi0ae0=
github.com/kovetskiy/ko v0.0.0-20190324102900-26b8dd0988bf/go.mod h1:5RTDadc76NCMKavfnEcGrGVdoQ02h8dLHBUEN4h3xsM=
github.com/kovetskiy/lorg v0.0.0-20180412114932-05d42d7f98ba h1:684OcooHjET2b2XWy4ZyIkZJ8CJ3GhHSCqLDeVIwsBo=
github.com/kovetskiy/lorg v0.0.0-20180412114932-05d42d7f98ba/go.mod h1:B8HeKAukXULNzWWsW5k/SQyDkiQZPn7lTBJDB46MZ9I=
github.com/kovetskiy/lorg v0.0.0-20200107130803-9a7136a95634 h1:szpgh20EtHoQhJ38jrp7S2nlrhf56GSwa4de0hMfc2U=
github.com/kovetskiy/lorg v0.0.0-20200107130803-9a7136a95634/go.mod h1:B8HeKAukXULNzWWsW5k/SQyDkiQZPn7lTBJDB46MZ9I=
github.com/kovetskiy/toml v0.2.0 h1:tMsPGWE3ejTjXop10/17b/tDtbwQJZdBfc0e+l3WndA=
github.com/kovetskiy/toml v0.2.0/go.mod h1:+nh++V8wCesSlfPA3DSXGO1hiAHDVHDqem4ixTsWuRY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/reconquest/cog v0.0.0-20190411204516-c6b6b90dcd40 h1:zUobRDLI5W17xv1Y5Z6jgBGdrh6JQgzxpkgvI9ecbzU=
github.com/reconquest/cog v0.0.0-20190411204516-c6b6b90dcd40/go.mod h1:IYiTfZ8/UKTz5svWOy+2ri5NuS+pJ3ynXMg8V0IHkXU=
github.com/reconquest/karma-go v0.0.0-20190930125156-7b5c19ad6eab h1:NPOguOXVFBXRaBt4uPQLhvLkNwQgT0M+PZwxBGxgrrQ=
github.com/reconquest/karma-go v0.0.0-20190930125156-7b5c19ad6eab/go.mod h1:oTXKs9J7KQ1gCpnvSwCbH9vlvELZFfUSbEbrr2ABeo0=
github.com/reconquest/cog v0.0.0-20191208202052-266c2467b936 h1:jSaVCkKLAGc8VWBRVKk0Ffxrv/NKD1ixkOyjwPWrPd4=
github.com/reconquest/cog v0.0.0-20191208202052-266c2467b936/go.mod h1:IYiTfZ8/UKTz5svWOy+2ri5NuS+pJ3ynXMg8V0IHkXU=
github.com/reconquest/colorgful v0.0.0-20190805091748-28d18b838c4a h1:LGyNu9LpBpJ+puxKBLuB8L+YTBgW8xLmiBqbTKuniec=
github.com/reconquest/colorgful v0.0.0-20190805091748-28d18b838c4a/go.mod h1:S7SVqgAB8m04PAsywFMzl2UfDPGfBGRqpk3wWZG2y70=
github.com/reconquest/karma-go v0.0.0-20200326104714-79480464fdb5 h1:zDWjDur+l8W6pKksuc1VdKcdYrfHrTO9jRN131XoG1g=
github.com/reconquest/karma-go v0.0.0-20200326104714-79480464fdb5/go.mod h1:oTXKs9J7KQ1gCpnvSwCbH9vlvELZFfUSbEbrr2ABeo0=
github.com/reconquest/loreley v0.0.0-20200601121626-621c1cd37fd1 h1:J1vuEtEaaHo01+gxE6jIMtTwLrYzsraHmnqbNvha2Jw=
github.com/reconquest/loreley v0.0.0-20200601121626-621c1cd37fd1/go.mod h1:1NF/j951kWm+ZnRXpOkBqweImgwhlzFVwTA4A0V7TEU=
github.com/reconquest/pkg v0.0.0-20201028091908-8e9a5e0226ef h1:7Vr6ItE8C41xDgTNQqX3ir3gtbSIzub0XhKp3FW6Li8=
github.com/reconquest/pkg v0.0.0-20201028091908-8e9a5e0226ef/go.mod h1:T3ej/s+DtNaxXSOhM8rZX9bTlhnfHeETwQpK5PAPvwo=
github.com/reconquest/regexputil-go v0.0.0-20160905154124-38573e70c1f4 h1:bcDXaTFC09IIg13Z8gfQHk4gSu001ET7ssW/wKRvPzg=
github.com/reconquest/regexputil-go v0.0.0-20160905154124-38573e70c1f4/go.mod h1:OI1di2iiFSwX3D70iZjzdmCPPfssjOl+HX40tI3VaXA=
github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c/go.mod h1:UrdRz5enIKZ63MEE3IF9l2/ebyx59GyGgPi+tICQdmM=
github.com/zazab/zhash v0.0.0-20170403032415-ad45b89afe7a h1:8gf6DUwu6F8Fh3rN8Ei9TM66KkWrNC04FP3HlcbxPuQ=
github.com/zazab/zhash v0.0.0-20170403032415-ad45b89afe7a/go.mod h1:P+yVThXQrjx7yGmgsdI4WQ/XDDmcyBMZzK1b39TXteA=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
13 changes: 10 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import (
"path/filepath"

"github.com/docopt/docopt-go"
"github.com/kovetskiy/lorg"
"github.com/kovetskiy/mark/pkg/confluence"
"github.com/kovetskiy/mark/pkg/log"
"github.com/kovetskiy/mark/pkg/mark"
"github.com/kovetskiy/mark/pkg/mark/includes"
"github.com/kovetskiy/mark/pkg/mark/macro"
"github.com/kovetskiy/mark/pkg/mark/stdlib"
"github.com/reconquest/karma-go"
"github.com/reconquest/pkg/log"
)

const (
Expand Down Expand Up @@ -132,7 +133,7 @@ Options:
)

func main() {
args, err := docopt.Parse(usage, nil, true, "3.2", false)
args, err := docopt.Parse(usage, nil, true, "3.3", false)
if err != nil {
panic(err)
}
Expand All @@ -144,7 +145,13 @@ func main() {
editLock = args["-k"].(bool)
)

log.Init(args["--debug"].(bool), args["--trace"].(bool))
if args["--debug"].(bool) {
log.SetLevel(lorg.LevelDebug)
}

if args["--trace"].(bool) {
log.SetLevel(lorg.LevelTrace)
}

config, err := LoadConfig(filepath.Join(os.Getenv("HOME"), ".config/mark"))
if err != nil {
Expand Down
42 changes: 29 additions & 13 deletions pkg/confluence/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import (
"os"
"strings"

"github.com/bndr/gopencils"
"github.com/kovetskiy/gopencils"
"github.com/kovetskiy/lorg"
"github.com/reconquest/karma-go"
"github.com/reconquest/pkg/log"
)

type User struct {
Expand Down Expand Up @@ -62,16 +64,31 @@ type form struct {
writer *multipart.Writer
}

type tracer struct {
prefix string
}

func (tracer *tracer) Printf(format string, args ...interface{}) {
log.Tracef(nil, tracer.prefix+" "+format, args...)
}

func NewAPI(baseURL string, username string, password string) *API {
auth := &gopencils.BasicAuth{username, password}

return &API{
rest: gopencils.Api(baseURL+"/rest/api", auth),
rest := gopencils.Api(baseURL+"/rest/api", auth)
json := gopencils.Api(
baseURL+"/rpc/json-rpc/confluenceservice-v2",
auth,
)

json: gopencils.Api(
baseURL+"/rpc/json-rpc/confluenceservice-v2",
auth,
),
if log.GetLevel() == lorg.LevelTrace {
rest.Logger = &tracer{"rest:"}
json.Logger = &tracer{"json-rpc:"}
}

return &API{
rest: rest,
json: json,
}
}

Expand Down Expand Up @@ -386,11 +403,11 @@ func (api *API) CreatePage(
},
},
"metadata": map[string]interface{}{
"properties": map[string]interface{}{
"editor": map[string]interface{}{
"value": "v2",
},
},
"properties": map[string]interface{}{
"editor": map[string]interface{}{
"value": "v2",
},
},
},
}

Expand Down Expand Up @@ -488,7 +505,6 @@ func (api *API) GetUserByName(name string) (*User, error) {
}

return &response.Results[0].User, nil

}

func (api *API) GetCurrentUser() (*User, error) {
Expand Down
101 changes: 0 additions & 101 deletions pkg/log/log.go

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/mark/ancestry.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"strings"

"github.com/kovetskiy/mark/pkg/confluence"
"github.com/kovetskiy/mark/pkg/log"
"github.com/reconquest/karma-go"
"github.com/reconquest/pkg/log"
)

func EnsureAncestry(
Expand Down
2 changes: 1 addition & 1 deletion pkg/mark/attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"strings"

"github.com/kovetskiy/mark/pkg/confluence"
"github.com/kovetskiy/mark/pkg/log"
"github.com/reconquest/karma-go"
"github.com/reconquest/pkg/log"
)

const (
Expand Down
16 changes: 5 additions & 11 deletions pkg/mark/includes/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,14 @@ import (

"gopkg.in/yaml.v2"

"github.com/kovetskiy/mark/pkg/log"
"github.com/reconquest/karma-go"
"github.com/reconquest/pkg/log"
)

var (
reIncludeDirective = regexp.MustCompile(
// <!-- Include: <template path>
// <optional yaml data> -->

`(?s)` + // dot capture newlines
/**/ `<!--\s*Include:\s*(?P<template>\S+)\s*` +
/* */ `(\n(?P<config>.*?))?-->`,
)
)
// <!-- Include: <template path>
// <optional yaml data> -->
var reIncludeDirective = regexp.MustCompile(
`(?s)<!--\s*Include:\s*(?P<template>\S+)\s*(\n(?P<config>.*?))?-->`)

func LoadTemplate(
path string,
Expand Down
2 changes: 1 addition & 1 deletion pkg/mark/macro/macro.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"strings"
"text/template"

"github.com/kovetskiy/mark/pkg/log"
"github.com/kovetskiy/mark/pkg/mark/includes"
"github.com/reconquest/karma-go"
"github.com/reconquest/pkg/log"
"github.com/reconquest/regexputil-go"
"gopkg.in/yaml.v2"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/mark/mark.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"strings"

"github.com/kovetskiy/mark/pkg/confluence"
"github.com/kovetskiy/mark/pkg/log"
"github.com/reconquest/karma-go"
"github.com/reconquest/pkg/log"
)

func ResolvePage(
Expand Down
2 changes: 1 addition & 1 deletion pkg/mark/markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"bytes"
"regexp"

"github.com/kovetskiy/mark/pkg/log"
"github.com/kovetskiy/mark/pkg/mark/stdlib"
"github.com/reconquest/pkg/log"
"github.com/russross/blackfriday"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/mark/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"regexp"
"strings"

"github.com/kovetskiy/mark/pkg/log"
"github.com/reconquest/pkg/log"
)

const (
Expand Down
Loading

0 comments on commit ec4b258

Please sign in to comment.