private void Op(KMSAudit.OpStatus opStatus, KMS.KMSOp op, string user, string key , string extraMsg) { if (!Strings.IsNullOrEmpty(user) && !Strings.IsNullOrEmpty(key) && (op != null) && AggregateOpsWhitelist.Contains(op)) { string cacheKey = CreateCacheKey(user, key, op); if (opStatus == KMSAudit.OpStatus.Unauthorized) { cache.Invalidate(cacheKey); AuditLog.Info("UNAUTHORIZED[op={}, key={}, user={}] {}", op, key, user, extraMsg); } else { try { KMSAudit.AuditEvent @event = cache.Get(cacheKey, new _Callable_161(key, user, op, extraMsg)); // Log first access (initialized as -1 so // incrementAndGet() == 0 implies first access) if (@event.GetAccessCount().IncrementAndGet() == 0) { @event.GetAccessCount().IncrementAndGet(); LogEvent(@event); } } catch (ExecutionException ex) { throw new RuntimeException(ex); } } } else { IList <string> kvs = new List <string>(); if (op != null) { kvs.AddItem("op=" + op); } if (!Strings.IsNullOrEmpty(key)) { kvs.AddItem("key=" + key); } if (!Strings.IsNullOrEmpty(user)) { kvs.AddItem("user="******"{} {}", opStatus.ToString(), extraMsg); } else { string join = Joiner.On(", ").Join(kvs); AuditLog.Info("{}[{}] {}", opStatus.ToString(), join, extraMsg); } } }
private void LogEvent(KMSAudit.AuditEvent @event) { AuditLog.Info("OK[op={}, key={}, user={}, accessCount={}, interval={}ms] {}", @event .GetOp(), @event.GetKeyName(), @event.GetUser(), @event.GetAccessCount().Get(), (Runtime.CurrentTimeMillis() - @event.GetStartTime()), @event.GetExtraMsg()); }