Commit bdb012ae authored by Adam Simpkins's avatar Adam Simpkins Committed by Facebook Github Bot

rename Logging.h to GLog.h

Summary:
Rename folly/Logging.h to folly/GLog.h.  This header primarily exists to just
include <glog/logging.h>, and it also defines a single `FB_LOG_EVERY_MS()`
macro.

I plan to move the folly/experimental/logging/ directory to folly/logging/
soon, and I want to avoid confusing between this `Logging.h` header and the
separate `folly/logging/` code.

Reviewed By: yfeldblum

Differential Revision: D7754543

fbshipit-source-id: c91b8016d303cd0fae9e688e8782b22d095a6554
parent afa77d5d
......@@ -676,6 +676,7 @@ if (BUILD_TESTS)
SOURCES FunctionTest.cpp
TEST function_ref_test SOURCES FunctionRefTest.cpp
TEST futex_test SOURCES FutexTest.cpp
TEST glog_test SOURCES GLogTest.cpp
TEST group_varint_test SOURCES GroupVarintTest.cpp
TEST group_varint_test_ssse3 SOURCES GroupVarintTest.cpp
TEST has_member_fn_traits_test SOURCES HasMemberFnTraitsTest.cpp
......@@ -692,7 +693,6 @@ if (BUILD_TESTS)
TEST lazy_test SOURCES LazyTest.cpp
TEST lock_traits_test SOURCES LockTraitsTest.cpp
TEST locks_test SOURCES SpinLockTest.cpp
TEST logging_test SOURCES LoggingTest.cpp
TEST math_test SOURCES MathTest.cpp
TEST map_util_test SOURCES MapUtilTest.cpp
TEST memcpy_test SOURCES MemcpyTest.cpp
......
......@@ -17,7 +17,7 @@
#include <iostream>
#include <folly/Logging.h>
#include <folly/GLog.h>
namespace folly {
......
/*
* Copyright 2012-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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <atomic>
#include <chrono>
#include <glog/logging.h>
#ifndef FB_LOG_EVERY_MS
/**
* Issues a LOG(severity) no more often than every
* milliseconds. Example:
*
* FB_LOG_EVERY_MS(INFO, 10000) << "At least ten seconds passed"
* " since you last saw this.";
*
* The implementation uses for statements to introduce variables in
* a nice way that doesn't mess surrounding statements. It is thread
* safe. Non-positive intervals will always log.
*/
#define FB_LOG_EVERY_MS(severity, milli_interval) \
for (decltype(milli_interval) FB_LEM_once = 1, \
FB_LEM_interval = (milli_interval); \
FB_LEM_once; ) \
for (::std::chrono::milliseconds::rep FB_LEM_prev, FB_LEM_now = \
FB_LEM_interval <= 0 ? 0 : \
::std::chrono::duration_cast< ::std::chrono::milliseconds>( \
::std::chrono::system_clock::now().time_since_epoch() \
).count(); \
FB_LEM_once; ) \
for (static ::std::atomic< ::std::chrono::milliseconds::rep> \
FB_LEM_hist; FB_LEM_once; FB_LEM_once = 0) \
if (FB_LEM_interval > 0 && \
(FB_LEM_now - (FB_LEM_prev = \
FB_LEM_hist.load(std::memory_order_acquire)) < \
FB_LEM_interval || \
!FB_LEM_hist.compare_exchange_strong(FB_LEM_prev,FB_LEM_now))) {\
} else \
LOG(severity)
#endif
......@@ -16,41 +16,4 @@
#pragma once
#include <atomic>
#include <chrono>
#include <glog/logging.h>
#ifndef FB_LOG_EVERY_MS
/**
* Issues a LOG(severity) no more often than every
* milliseconds. Example:
*
* FB_LOG_EVERY_MS(INFO, 10000) << "At least ten seconds passed"
* " since you last saw this.";
*
* The implementation uses for statements to introduce variables in
* a nice way that doesn't mess surrounding statements. It is thread
* safe. Non-positive intervals will always log.
*/
#define FB_LOG_EVERY_MS(severity, milli_interval) \
for (decltype(milli_interval) FB_LEM_once = 1, \
FB_LEM_interval = (milli_interval); \
FB_LEM_once; ) \
for (::std::chrono::milliseconds::rep FB_LEM_prev, FB_LEM_now = \
FB_LEM_interval <= 0 ? 0 : \
::std::chrono::duration_cast< ::std::chrono::milliseconds>( \
::std::chrono::system_clock::now().time_since_epoch() \
).count(); \
FB_LEM_once; ) \
for (static ::std::atomic< ::std::chrono::milliseconds::rep> \
FB_LEM_hist; FB_LEM_once; FB_LEM_once = 0) \
if (FB_LEM_interval > 0 && \
(FB_LEM_now - (FB_LEM_prev = \
FB_LEM_hist.load(std::memory_order_acquire)) < \
FB_LEM_interval || \
!FB_LEM_hist.compare_exchange_strong(FB_LEM_prev,FB_LEM_now))) {\
} else \
LOG(severity)
#endif
#include <folly/GLog.h> // @shim
......@@ -266,6 +266,7 @@ nobase_follyinclude_HEADERS = \
gen/ParallelMap-inl.h \
gen/String.h \
gen/String-inl.h \
GLog.h \
GroupVarint.h \
Hash.h \
IPAddress.h \
......
......@@ -16,7 +16,7 @@
#include <folly/detail/MemoryIdler.h>
#include <folly/Logging.h>
#include <folly/GLog.h>
#include <folly/Portability.h>
#include <folly/ScopeGuard.h>
#include <folly/concurrency/CacheLocality.h>
......
......@@ -16,7 +16,7 @@
#include <folly/io/async/SSLOptions.h>
#include <folly/Format.h>
#include <folly/Logging.h>
#include <glog/logging.h>
namespace folly {
namespace ssl {
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
#include <folly/Logging.h>
#include <folly/GLog.h>
#include <folly/Benchmark.h>
......@@ -41,7 +41,7 @@ BENCHMARK(dev_null_log_overhead, iter) {
}
// ============================================================================
// folly/test/LoggingTest.cpp relative time/iter iters/s
// folly/test/GLogBenchmark.cpp relative time/iter iters/s
// ============================================================================
// skip_overhead 36.37ns 27.49M
// dev_null_log_overhead 2.61us 382.57K
......
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
#include <folly/Logging.h>
#include <folly/GLog.h>
#include <folly/portability/GTest.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment