/*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <folly/Conv.h>
#include <folly/Format.h>
+#include <folly/Optional.h>
#include <folly/String.h>
#include <glog/logging.h>
AutoTimer& operator=(AutoTimer&&) = default;
~AutoTimer() {
- log(destructionMessage_);
+ if (destructionMessage_) {
+ log(destructionMessage_.value());
+ }
}
DoubleSeconds log(StringPiece msg = "") {
return duration;
}
- const std::string destructionMessage_;
+ Optional<std::string> destructionMessage_;
std::chrono::time_point<Clock> start_ = Clock::now();
DoubleSeconds minTimeToLog_;
Logger logger_;
}
}
};
-}
+} // namespace folly