mirror of
https://github.com/kovetskiy/mark.git
synced 2026-05-02 05:12:35 +00:00
trace level is very verbose now
This commit is contained in:
@@ -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 {
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -488,7 +505,6 @@ func (api *API) GetUserByName(name string) (*User, error) {
|
||||
}
|
||||
|
||||
return &response.Results[0].User, nil
|
||||
|
||||
}
|
||||
|
||||
func (api *API) GetCurrentUser() (*User, error) {
|
||||
|
||||
101
pkg/log/log.go
101
pkg/log/log.go
@@ -1,101 +0,0 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"github.com/kovetskiy/lorg"
|
||||
"github.com/reconquest/cog"
|
||||
"github.com/reconquest/karma-go"
|
||||
)
|
||||
|
||||
var (
|
||||
log *cog.Logger
|
||||
)
|
||||
|
||||
func Init(debug, trace bool) {
|
||||
stderr := lorg.NewLog()
|
||||
stderr.SetIndentLines(true)
|
||||
stderr.SetFormat(
|
||||
lorg.NewFormat("${time} ${level:[%s]:right:short} ${prefix}%s"),
|
||||
)
|
||||
|
||||
log = cog.NewLogger(stderr)
|
||||
|
||||
if debug {
|
||||
log.SetLevel(lorg.LevelDebug)
|
||||
}
|
||||
|
||||
if trace {
|
||||
log.SetLevel(lorg.LevelTrace)
|
||||
}
|
||||
}
|
||||
|
||||
func Fatalf(
|
||||
reason error,
|
||||
message string,
|
||||
args ...interface{},
|
||||
) {
|
||||
log.Fatalf(reason, message, args...)
|
||||
}
|
||||
|
||||
func Errorf(
|
||||
reason error,
|
||||
message string,
|
||||
args ...interface{},
|
||||
) {
|
||||
log.Errorf(reason, message, args...)
|
||||
}
|
||||
|
||||
func Warningf(
|
||||
reason error,
|
||||
message string,
|
||||
args ...interface{},
|
||||
) {
|
||||
log.Warningf(reason, message, args...)
|
||||
}
|
||||
|
||||
func Infof(
|
||||
context *karma.Context,
|
||||
message string,
|
||||
args ...interface{},
|
||||
) {
|
||||
log.Infof(context, message, args...)
|
||||
}
|
||||
|
||||
func Debugf(
|
||||
context *karma.Context,
|
||||
message string,
|
||||
args ...interface{},
|
||||
) {
|
||||
log.Debugf(context, message, args...)
|
||||
}
|
||||
|
||||
func Tracef(
|
||||
context *karma.Context,
|
||||
message string,
|
||||
args ...interface{},
|
||||
) {
|
||||
log.Tracef(context, message, args...)
|
||||
}
|
||||
|
||||
func Fatal(values ...interface{}) {
|
||||
log.Fatal(values...)
|
||||
}
|
||||
|
||||
func Error(values ...interface{}) {
|
||||
log.Error(values...)
|
||||
}
|
||||
|
||||
func Warning(values ...interface{}) {
|
||||
log.Warning(values...)
|
||||
}
|
||||
|
||||
func Info(values ...interface{}) {
|
||||
log.Info(values...)
|
||||
}
|
||||
|
||||
func Debug(values ...interface{}) {
|
||||
log.Debug(values...)
|
||||
}
|
||||
|
||||
func Trace(values ...interface{}) {
|
||||
log.Trace(values...)
|
||||
}
|
||||
@@ -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(
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/kovetskiy/mark/pkg/log"
|
||||
"github.com/reconquest/pkg/log"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"text/template"
|
||||
|
||||
"github.com/kovetskiy/mark/pkg/confluence"
|
||||
"github.com/kovetskiy/mark/pkg/log"
|
||||
"github.com/kovetskiy/mark/pkg/mark/macro"
|
||||
"github.com/reconquest/pkg/log"
|
||||
|
||||
"github.com/reconquest/karma-go"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user