Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IRMA
Github mirrors
irmago
Commits
4e1ee035
Commit
4e1ee035
authored
Jun 29, 2019
by
Sietse Ringers
Browse files
feat: improve HTTPTransport logging
parent
9c11b550
Changes
1
Hide whitespace changes
Inline
Side-by-side
transport.go
View file @
4e1ee035
...
@@ -129,17 +129,16 @@ func (transport *HTTPTransport) jsonRequest(url string, method string, result in
...
@@ -129,17 +129,16 @@ func (transport *HTTPTransport) jsonRequest(url string, method string, result in
if
object
!=
nil
{
if
object
!=
nil
{
var
objstr
string
var
objstr
string
if
objstr
,
isstr
=
object
.
(
string
);
isstr
{
if
objstr
,
isstr
=
object
.
(
string
);
isstr
{
Logger
.
Trace
(
"transport: body: "
,
objstr
)
reader
=
bytes
.
NewBuffer
([]
byte
(
objstr
))
reader
=
bytes
.
NewBuffer
([]
byte
(
objstr
))
}
else
{
}
else
{
marshaled
,
err
:=
json
.
Marshal
(
object
)
marshaled
,
err
:=
json
.
Marshal
(
object
)
if
err
!=
nil
{
if
err
!=
nil
{
return
&
SessionError
{
ErrorType
:
ErrorSerialization
,
Err
:
err
}
return
&
SessionError
{
ErrorType
:
ErrorSerialization
,
Err
:
err
}
}
}
Logger
.
Debugf
(
"%s %s: %s
\n
"
,
method
,
url
,
string
(
marshaled
))
Logger
.
Trace
(
"transport: body: "
,
string
(
marshaled
))
reader
=
bytes
.
NewBuffer
(
marshaled
)
reader
=
bytes
.
NewBuffer
(
marshaled
)
}
}
}
else
{
Logger
.
Debugf
(
"%s %s
\n
"
,
method
,
url
)
}
}
res
,
err
:=
transport
.
request
(
url
,
method
,
reader
,
isstr
)
res
,
err
:=
transport
.
request
(
url
,
method
,
reader
,
isstr
)
...
@@ -160,11 +159,11 @@ func (transport *HTTPTransport) jsonRequest(url string, method string, result in
...
@@ -160,11 +159,11 @@ func (transport *HTTPTransport) jsonRequest(url string, method string, result in
if
err
!=
nil
||
apierr
.
ErrorName
==
""
{
// Not an ApiErrorMessage
if
err
!=
nil
||
apierr
.
ErrorName
==
""
{
// Not an ApiErrorMessage
return
&
SessionError
{
ErrorType
:
ErrorServerResponse
,
RemoteStatus
:
res
.
StatusCode
}
return
&
SessionError
{
ErrorType
:
ErrorServerResponse
,
RemoteStatus
:
res
.
StatusCode
}
}
}
Logger
.
Debugf
(
"ERROR
: %+v
\n
"
,
apierr
)
Logger
.
Tracef
(
"transport: error
: %+v"
,
apierr
)
return
&
SessionError
{
ErrorType
:
ErrorApi
,
RemoteStatus
:
res
.
StatusCode
,
RemoteError
:
apierr
}
return
&
SessionError
{
ErrorType
:
ErrorApi
,
RemoteStatus
:
res
.
StatusCode
,
RemoteError
:
apierr
}
}
}
Logger
.
Debugf
(
"RESPONSE
: %s
\n
"
,
string
(
body
))
Logger
.
Tracef
(
"transport: response
: %s"
,
string
(
body
))
if
_
,
resultstr
:=
result
.
(
*
string
);
resultstr
{
if
_
,
resultstr
:=
result
.
(
*
string
);
resultstr
{
*
result
.
(
*
string
)
=
string
(
body
)
*
result
.
(
*
string
)
=
string
(
body
)
}
else
{
}
else
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment