Skip to content

Commit de3d0b6

Browse files
jon-whitarekkas
authored andcommitted
Fixes logger for AuditLoggerInfo when none is provided (#109)
* Fix logger for AuditLoggerInfo when none is provided. This commit fixes an issue with the AuditLoggerInfo structure where a user may fail to provide a logger at the time the struct is instantiated. The method logger() for the AuditLoggerInfo structure handles this case by instantiating a default logger that logs to Stderr if no logger instance is provided. The logger() method simply needs to be used, and this commit adds that functionality.
1 parent 5453007 commit de3d0b6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

audit_logger_info.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ func (a *AuditLoggerInfo) LogRejectedAccessRequest(r *Request, p Policies, d Pol
2222
if len(d) > 1 {
2323
allowed := joinPoliciesNames(d[0 : len(d)-1])
2424
denied := d[len(d)-1].GetID()
25-
a.Logger.Printf("policies %s allow access, but policy %s forcefully denied it", allowed, denied)
25+
a.logger().Printf("policies %s allow access, but policy %s forcefully denied it", allowed, denied)
2626
} else if len(d) == 1 {
2727
denied := d[len(d)-1].GetID()
28-
a.Logger.Printf("policy %s forcefully denied the access", denied)
28+
a.logger().Printf("policy %s forcefully denied the access", denied)
2929
} else {
30-
a.Logger.Printf("no policy allowed access")
30+
a.logger().Printf("no policy allowed access")
3131
}
3232
}
3333

3434
func (a *AuditLoggerInfo) LogGrantedAccessRequest(r *Request, p Policies, d Policies) {
35-
a.Logger.Printf("policies %s allow access", joinPoliciesNames(d))
35+
a.logger().Printf("policies %s allow access", joinPoliciesNames(d))
3636
}
3737

3838
func joinPoliciesNames(policies Policies) string {

0 commit comments

Comments
 (0)