Skip to content

Commit 9c12708

Browse files
gitbw95bowang
authored andcommitted
Fix an import issue in fbcode. (#10604)
Summary: This should fix an import issue detected in meta internal tests. Pull Request resolved: #10604 Test Plan: Unit Tests. Reviewed By: hx235 Differential Revision: D39120414 Pulled By: gitbw95 fbshipit-source-id: dbd016d7f47b9f54aab5ea61e8d3cd79734f46af
1 parent 2f73550 commit 9c12708

File tree

5 files changed

+39
-18
lines changed

5 files changed

+39
-18
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,7 @@ set(SOURCES
827827
util/slice.cc
828828
util/file_checksum_helper.cc
829829
util/status.cc
830+
util/stderr_logger.cc
830831
util/string_util.cc
831832
util/thread_local.cc
832833
util/threadpool_imp.cc

TARGETS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ cpp_library_wrapper(name="rocksdb_lib", srcs=[
252252
"util/ribbon_config.cc",
253253
"util/slice.cc",
254254
"util/status.cc",
255+
"util/stderr_logger.cc",
255256
"util/string_util.cc",
256257
"util/thread_local.cc",
257258
"util/threadpool_imp.cc",
@@ -589,6 +590,7 @@ cpp_library_wrapper(name="rocksdb_whole_archive_lib", srcs=[
589590
"util/ribbon_config.cc",
590591
"util/slice.cc",
591592
"util/status.cc",
593+
"util/stderr_logger.cc",
592594
"util/string_util.cc",
593595
"util/thread_local.cc",
594596
"util/threadpool_imp.cc",

src.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ LIB_SOURCES = \
239239
util/slice.cc \
240240
util/file_checksum_helper.cc \
241241
util/status.cc \
242+
util/stderr_logger.cc \
242243
util/string_util.cc \
243244
util/thread_local.cc \
244245
util/threadpool_imp.cc \

util/stderr_logger.cc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Meta Platforms, Inc. and affiliates.
2+
//
3+
// This source code is licensed under both the GPLv2 (found in the
4+
// COPYING file in the root directory) and Apache 2.0 License
5+
// (found in the LICENSE.Apache file in the root directory).
6+
7+
#include "util/stderr_logger.h"
8+
9+
#include "port/sys_time.h"
10+
11+
namespace ROCKSDB_NAMESPACE {
12+
StderrLogger::~StderrLogger() {}
13+
14+
void StderrLogger::Logv(const char* format, va_list ap) {
15+
const uint64_t thread_id = Env::Default()->GetThreadID();
16+
17+
port::TimeVal now_tv;
18+
port::GetTimeOfDay(&now_tv, nullptr);
19+
const time_t seconds = now_tv.tv_sec;
20+
struct tm t;
21+
port::LocalTimeR(&seconds, &t);
22+
fprintf(stderr, "%04d/%02d/%02d-%02d:%02d:%02d.%06d %llx ", t.tm_year + 1900,
23+
t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec,
24+
static_cast<int>(now_tv.tv_usec),
25+
static_cast<long long unsigned int>(thread_id));
26+
27+
vfprintf(stderr, format, ap);
28+
fprintf(stderr, "\n");
29+
}
30+
} // namespace ROCKSDB_NAMESPACE

util/stderr_logger.h

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
1+
// Copyright (c) Meta Platforms, Inc. and affiliates.
2+
//
23
// This source code is licensed under both the GPLv2 (found in the
34
// COPYING file in the root directory) and Apache 2.0 License
45
// (found in the LICENSE.Apache file in the root directory).
@@ -8,7 +9,6 @@
89
#include <stdarg.h>
910
#include <stdio.h>
1011

11-
#include "port/sys_time.h"
1212
#include "rocksdb/env.h"
1313

1414
namespace ROCKSDB_NAMESPACE {
@@ -19,26 +19,13 @@ class StderrLogger : public Logger {
1919
explicit StderrLogger(const InfoLogLevel log_level = InfoLogLevel::INFO_LEVEL)
2020
: Logger(log_level) {}
2121

22+
~StderrLogger() override;
23+
2224
// Brings overloaded Logv()s into scope so they're not hidden when we override
2325
// a subset of them.
2426
using Logger::Logv;
2527

26-
virtual void Logv(const char* format, va_list ap) override {
27-
const uint64_t thread_id = Env::Default()->GetThreadID();
28-
29-
port::TimeVal now_tv;
30-
port::GetTimeOfDay(&now_tv, nullptr);
31-
const time_t seconds = now_tv.tv_sec;
32-
struct tm t;
33-
port::LocalTimeR(&seconds, &t);
34-
fprintf(stderr, "%04d/%02d/%02d-%02d:%02d:%02d.%06d %llx ",
35-
t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min,
36-
t.tm_sec, static_cast<int>(now_tv.tv_usec),
37-
static_cast<long long unsigned int>(thread_id));
38-
39-
vfprintf(stderr, format, ap);
40-
fprintf(stderr, "\n");
41-
}
28+
virtual void Logv(const char* format, va_list ap) override;
4229
};
4330

4431
} // namespace ROCKSDB_NAMESPACE

0 commit comments

Comments
 (0)