Fix copyright lines
[folly.git] / folly / experimental / logging / StandardLogHandler.h
index dfd69c506cdd7a403df3be47412462caca5ab23e..ea904dfdd7dec9ba754dd19b11001ad847d4496f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004-present Facebook, Inc.
+ * Copyright 2017-present Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
 #include <folly/File.h>
 #include <folly/Range.h>
 #include <folly/experimental/logging/LogHandler.h>
+#include <folly/experimental/logging/LogHandlerConfig.h>
 
 namespace folly {
 
@@ -40,10 +41,25 @@ class LogWriter;
 class StandardLogHandler : public LogHandler {
  public:
   StandardLogHandler(
+      LogHandlerConfig config,
       std::shared_ptr<LogFormatter> formatter,
       std::shared_ptr<LogWriter> writer);
   ~StandardLogHandler();
 
+  /**
+   * Get the LogFormatter used by this handler.
+   */
+  const std::shared_ptr<LogFormatter>& getFormatter() const {
+    return formatter_;
+  }
+
+  /**
+   * Get the LogWriter used by this handler.
+   */
+  const std::shared_ptr<LogWriter>& getWriter() const {
+    return writer_;
+  }
+
   /**
    * Get the handler's current LogLevel.
    *
@@ -67,9 +83,21 @@ class StandardLogHandler : public LogHandler {
       const LogMessage& message,
       const LogCategory* handlerCategory) override;
 
+  void flush() override;
+
+  LogHandlerConfig getConfig() const override;
+
  private:
   std::atomic<LogLevel> level_{LogLevel::NONE};
-  std::shared_ptr<LogFormatter> formatter_;
-  std::shared_ptr<LogWriter> writer_;
+
+  // The following variables are const, and cannot be modified after the
+  // log handler is constructed.  This allows us to access them without
+  // locking when handling a message.  To change these values, create a new
+  // StandardLogHandler object and replace the old handler with the new one in
+  // the LoggerDB.
+
+  const std::shared_ptr<LogFormatter> formatter_;
+  const std::shared_ptr<LogWriter> writer_;
+  const LogHandlerConfig config_;
 };
-}
+} // namespace folly