Skip to content
This repository has been archived by the owner on Jul 26, 2021. It is now read-only.

How to change the log level for go-cloudstack module? #120

Closed
synergiator opened this issue Sep 19, 2019 · 4 comments
Closed

How to change the log level for go-cloudstack module? #120

synergiator opened this issue Sep 19, 2019 · 4 comments

Comments

@synergiator
Copy link

Hi,

while doing problem analysis for the docker machine cloud stack driver, which depends on go-cloudstack, I would like to know whether it's possible to increase the log level of this module (at runtime either statically reaching out from the driver code).

@synergiator synergiator changed the title Changing log level How to change the log level for go-cloudstack module? Sep 19, 2019
@svanharmelen
Copy link
Member

I'm afraid this module currently doesn't log much. I guess the one thing that should be reasonable easy to add is logging API requests and responses. Is that what you are looking for?

@synergiator
Copy link
Author

Hi, @svanharmelen , yes, at least for most critical async jobs. Otherwise while debugging the docker machine cloudstack driver it's quite hard to understand what is happening behind the scenes especially under high load.

@olivierlemasle
Copy link

@svanharmelen I also think that adding logging would be useful, but as there's never consensus on what to log or which logging library to use (log, zap, logrus, etc.), what would you think of adding some "hooks", optional functions that would be called before and after the actual http request? The user of CloudStack client could then provide its own logging or tracing logic.

IMHO, the best would be to also add an optional context.Context to all API functions, in order to make it possible to do contextual tracing for example.

A possible signature for these hooks could be:

// PreRequestHook would be called in newRequest, just before the HTTP request call.
type PreRequestHook func(ctx context.Context, api string, params url.Values)

// PostRequestHook would be called in each generated client function,
// just after the Unmarshal step.
type PostRequestHook func(ctx context.Context, rawResp json.RawMessage, err error, resp interface{})

I can contribute and submit a PR if you are ok with that.

@svanharmelen
Copy link
Member

I'm going to close this issue as I'm about to archive this repository. Development of this package has been moved to the Apache Foundation. Please find the new home for this package here: https://github.com/apache/cloudstack-go

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants