Skip to content

Commit

Permalink
use log15.v2 instead of log
Browse files Browse the repository at this point in the history
  • Loading branch information
Tamás Gulácsi committed Sep 2, 2014
1 parent 89550ca commit 680602c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
19 changes: 10 additions & 9 deletions generator/gowsdl.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"errors"
"fmt"
"io/ioutil"
"log"
"net"
"net/http"
"net/url"
Expand Down Expand Up @@ -35,7 +34,8 @@ var cacheDir = filepath.Join(os.TempDir(), "gowsdl-cache")
func init() {
err := os.MkdirAll(cacheDir, 0700)
if err != nil {
log.Fatalf("Unable to create cache directory: %s", err.Error())
Log.Crit("Create cache directory", "error", err)
os.Exit(1)
}
}

Expand Down Expand Up @@ -71,7 +71,8 @@ func downloadFile(url string, ignoreTls bool) ([]byte, error) {
func NewGoWsdl(file, pkg string, ignoreTls bool) (*GoWsdl, error) {
file = strings.TrimSpace(file)
if file == "" {
log.Fatalln("WSDL file is required to generate Go proxy")
Log.Crit("WSDL file is required to generate Go proxy")
os.Exit(2)
}

pkg = strings.TrimSpace(pkg)
Expand Down Expand Up @@ -103,7 +104,7 @@ func (g *GoWsdl) Start() (map[string][]byte, error) {

gocode["types"], err = g.genTypes()
if err != nil {
log.Println(err)
Log.Error("genTypes", "error", err)
}
}()

Expand All @@ -114,15 +115,15 @@ func (g *GoWsdl) Start() (map[string][]byte, error) {

gocode["operations"], err = g.genOperations()
if err != nil {
log.Println(err)
Log.Error("genOperations", "error", err)
}
}()

wg.Wait()

gocode["header"], err = g.genHeader()
if err != nil {
log.Println(err)
Log.Error("genHeader", "error", err)
}

return gocode, nil
Expand All @@ -133,14 +134,14 @@ func (g *GoWsdl) unmarshal() error {

parsedUrl, err := url.Parse(g.file)
if parsedUrl.Scheme == "" {
log.Printf("Reading file %s...\n", g.file)
Log.Info("Reading", "file", g.file)

data, err = ioutil.ReadFile(g.file)
if err != nil {
return err
}
} else {
log.Printf("Downloading %s...\n", g.file)
Log.Info("Downloading", "file", g.file)

data, err = downloadFile(g.file, g.ignoreTls)
if err != nil {
Expand Down Expand Up @@ -184,7 +185,7 @@ func (g *GoWsdl) resolveXsdExternals(schema *XsdSchema, url *url.URL) error {
schemaLocation = url.Scheme + "://" + url.Host + schemaLocation
}

log.Printf("Downloading external schema: %s\n", schemaLocation)
Log.Info("Downloading external schema", "location", schemaLocation)

data, err := downloadFile(schemaLocation, g.ignoreTls)
newschema := &XsdSchema{}
Expand Down
11 changes: 9 additions & 2 deletions generator/soap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@ import (
"crypto/tls"
"encoding/xml"
"io/ioutil"
"log"
"net/http"

"gopkg.in/inconshreveable/log15.v2"
)

var Log = log15.New()

func init() {
Log.SetHandler(log15.DiscardHandler())
}

type SoapEnvelope struct {
XMLName xml.Name `xml:"http://schemas.xmlsoap.org/soap/envelope/ Envelope"`
EncodingStyle string `xml:"http://schemas.xmlsoap.org/soap/encoding/ encodingStyle,attr"`
Expand Down Expand Up @@ -98,7 +105,7 @@ func (s *SoapClient) Call(soapAction string, request, response interface{}) erro
}

if respEnvelope.Body.Body == "" {
log.Printf("%#v\n", respEnvelope.Body)
Log.Warn("empty response body", "envelope", respEnvelope, "body", string(body))
return nil
}

Expand Down

0 comments on commit 680602c

Please sign in to comment.