Skip to content

Commit

Permalink
## [2.0.4] - 2024-03-04
Browse files Browse the repository at this point in the history
### Added
- Added custom logger. Censure API Key.
  • Loading branch information
fmunozmiranda committed Mar 4, 2024
1 parent 3a13157 commit 3f0fe4c
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.0.4] - 2024-03-04
### Added
- Added custom logger. Censure API Key.

## [2.0.3] - 2024-03-03
### Changed
- `Rate-Limit` bug fixed.
Expand Down Expand Up @@ -1299,4 +1303,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

[2.0.0]: https://github.com/meraki/dashboard-api-go/commits/v2.0.0
[2.0.1]: https://github.com/meraki/dashboard-api-go/compare/v2.0.0...2.0.1
[Unreleased]: https://github.com/meraki/dashboard-api-go/compare/v2.0.0...main
[2.0.2]: https://github.com/meraki/dashboard-api-go/compare/v2.0.1...2.0.2
[2.0.3]: https://github.com/meraki/dashboard-api-go/compare/v2.0.2...2.0.3
[2.0.4]: https://github.com/meraki/dashboard-api-go/compare/v2.0.3...2.0.4
[Unreleased]: https://github.com/meraki/dashboard-api-go/compare/v2.0.4...main
4 changes: 2 additions & 2 deletions sdk/api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ func NewClient() (*Client, error) {
return c, err
}

c.SetUserAgent("MerakiGolang/2.0.2 Cisco")

c.SetUserAgent("MerakiGolang/2.0.4 Cisco")
c.common.client.SetLogger(&CustomLogger{})
c.common.client.AddRetryCondition(
// RetryConditionFunc type is for retry condition function
// input: non-nil Response OR request execution error
Expand Down
37 changes: 37 additions & 0 deletions sdk/logger.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package meraki

import (
"fmt"
"log"
"regexp"
)

type CustomLogger struct{}

// Debugf implements the resty.Logger interface
func (l *CustomLogger) Debugf(format string, v ...interface{}) {
// Convertir la salida de depuración a una cadena
// Convertir el formato y los argumentos a una cadena de depuración
message := fmt.Sprintf(format, v...)

// Censurar el encabezado de autorización
// re := regexp.MustCompile(`Authorization: .*`)
// censoredMessage := re.ReplaceAllString(message, "Authorization: [censored]")
re := regexp.MustCompile(`Authorization: Bearer [a-zA-Z0-9]+([a-zA-Z0-9]{5})`)
censoredMessage := re.ReplaceAllString(message, "Authorization: Bearer ****$1")

// Imprimir la salida de depuración censurada
log.Print(censoredMessage)

}

// Errorf implements the resty.Logger interface
func (l *CustomLogger) Errorf(format string, v ...interface{}) {
// Log errors
log.Printf(format, v...)
}

func (l *CustomLogger) Warnf(format string, v ...interface{}) {
// Log warnings
log.Printf(format, v...)
}

0 comments on commit 3f0fe4c

Please sign in to comment.