MCPcopy Index your code
hub / github.com/apache/casbin / createEnforceLogEntry

Method createEnforceLogEntry

util_log.go:97–122  ·  view source on GitHub ↗

createEnforceLogEntry creates a log entry for enforce events with subject, object, action, and domain extracted from rvals.

(rvals []interface{})

Source from the content-addressed store, hash-verified

95
96// createEnforceLogEntry creates a log entry for enforce events with subject, object, action, and domain extracted from rvals.
97func (e *Enforcer) createEnforceLogEntry(rvals []interface{}) *log.LogEntry {
98 entry := &log.LogEntry{
99 EventType: log.EventEnforce,
100 }
101 if len(rvals) > 0 {
102 if s, isString := rvals[0].(string); isString {
103 entry.Subject = s
104 }
105 }
106 if len(rvals) > 1 {
107 if o, isString := rvals[1].(string); isString {
108 entry.Object = o
109 }
110 }
111 if len(rvals) > 2 {
112 if a, isString := rvals[2].(string); isString {
113 entry.Action = a
114 }
115 }
116 if len(rvals) > 3 {
117 if d, isString := rvals[3].(string); isString {
118 entry.Domain = d
119 }
120 }
121 return entry
122}
123
124// onLogBeforeEventInEnforce initializes logging for Enforce operation.
125func (e *Enforcer) onLogBeforeEventInEnforce(rvals []interface{}) *log.LogEntry {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected