void handle(HookContext hookContext) {
      if (logger == null) {
        return;
      }
      // Note: same hookContext object is used for all the events for a given query, if we try to
      // do it async we have concurrency issues and when query cache is enabled, post event comes
      // before we start the pre hook processing and causes inconsistent events publishing.
      QueryPlan plan = hookContext.getQueryPlan();
      if (plan == null) {
        LOG.debug("Received null query plan.");
        return;
      }
      if (!includedOperationSet.contains(plan.getOperationName())) {
        LOG.debug("Not logging events of operation type : {}", plan.getOperationName());
        return;
      }
      HiveHookEventProtoPartialBuilder event;
      switch (hookContext.getHookType()) {
      case PRE_EXEC_HOOK:
        event = getPreHookEvent(hookContext);
        break;
      case POST_EXEC_HOOK:
        event = getPostHookEvent(hookContext, true);
        break;
      case ON_FAILURE_HOOK:
        event = getPostHookEvent(hookContext, false);
        break;
      default:
        LOG.warn("Ignoring event of type: {}", hookContext.getHookType());
        event = null;
      }
      if (event != null) {
        try {
          // ScheduledThreadPoolExecutor uses an unbounded queue which cannot be replaced with a bounded queue.
          // Therefore checking queue capacity manually here.
          if (logWriter.getQueue().size() < queueCapacity) {
            logWriter.execute(() -> writeEvent(event));
          } else {
            LOG.warn("Writer queue full ignoring event {} for query {}",
              hookContext.getHookType(), plan.getQueryId());
          }
        } catch (RejectedExecutionException e) {
          LOG.warn("Writer queue full ignoring event {} for query {}",
            hookContext.getHookType(), plan.getQueryId());
        }
      }
    }
Log events from hive hook using protobuf serialized format, partitioned by date.
ql/src/java/org/apache/hadoop/hive/ql/hooks/HiveProtoLoggingHook.java