Skip to content

Improve cache debug logging #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions powerdns/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ func NewClient(serverURL string, apiKey string, configTLS *tls.Config, cacheEnab
return nil, fmt.Errorf("Error while creating client: %s", err)
}
DefaultCacheSize = cacheSize * 1024 * 1024
log.Printf("[DEBUG] Caching: Enabled with DefaultCacheSize %d bytes", DefaultCacheSize)
} else {
log.Printf("[DEBUG] Caching: Disabled")
}

client := Client{
Expand Down Expand Up @@ -491,10 +494,14 @@ func (client *Client) ListRecords(zone string) ([]Record, error) {

err = client.Cache.Set([]byte(zone), cacheValue, client.CacheTTL)
if err != nil {
return nil, fmt.Errorf("The cache for REST API requests is enabled but the size isn't enough: cacheSize: %db \n %s",
DefaultCacheSize, err)
return nil, fmt.Errorf("The cache for REST API requests is enabled but the size isn't enough: cacheSize: %db, cacheValue length: %db \n %s",
DefaultCacheSize, len(cacheValue), err)
}

log.Printf("[DEBUG] Caching: Cache miss for %s", zone)
}
} else {
log.Printf("[DEBUG] Caching: Cache hit for %s", zone)
}

records := zoneInfo.Records
Expand Down