-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Added - Added custom logger. Censure API Key.
- Loading branch information
1 parent
3a13157
commit 3f0fe4c
Showing
3 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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...) | ||
} |