Skip to content

Commit

Permalink
clean unused overload
Browse files Browse the repository at this point in the history
  • Loading branch information
esigo committed Dec 16, 2021
1 parent 5f612dc commit a74d784
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 104 deletions.
10 changes: 3 additions & 7 deletions api/include/opentelemetry/logs/logger_provider.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,9 @@ class LoggerProvider
*
*/

virtual nostd::shared_ptr<Logger> GetLogger(nostd::string_view logger_name,
nostd::string_view options = "",
nostd::string_view schema_url = "") = 0;

virtual nostd::shared_ptr<Logger> GetLogger(nostd::string_view logger_name,
nostd::span<nostd::string_view> args,
nostd::string_view schema_url = "") = 0;
virtual nostd::shared_ptr<Logger> GetLogger(nostd::string_view library_name,
nostd::string_view library_version = "",
nostd::string_view schema_url = "") = 0;
};
} // namespace logs
OPENTELEMETRY_END_NAMESPACE
Expand Down
13 changes: 3 additions & 10 deletions api/include/opentelemetry/logs/noop.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,9 @@ class NoopLoggerProvider final : public opentelemetry::logs::LoggerProvider
nostd::shared_ptr<opentelemetry::logs::NoopLogger>(new opentelemetry::logs::NoopLogger)}
{}

nostd::shared_ptr<Logger> GetLogger(nostd::string_view logger_name,
nostd::string_view options,
nostd::string_view schema_url = "") override
{
return logger_;
}

nostd::shared_ptr<Logger> GetLogger(nostd::string_view logger_name,
nostd::span<nostd::string_view> args,
nostd::string_view schema_url = "") override
nostd::shared_ptr<Logger> GetLogger(nostd::string_view library_name,
nostd::string_view library_version = "",
nostd::string_view schema_url = "") override
{
return logger_;
}
Expand Down
21 changes: 0 additions & 21 deletions api/test/logs/logger_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,6 @@ TEST(Logger, GetLoggerDefault)
EXPECT_EQ(name, "noop logger");
}

// Test the two additional overloads for GetLogger()
TEST(Logger, GetNoopLoggerNameWithArgs)
{
auto lp = Provider::GetLoggerProvider();

// GetLogger(name, list(args))
std::array<string_view, 1> sv{"string"};
span<string_view> args{sv};
lp->GetLogger("NoopLoggerWithArgs", args);

// GetLogger(name, string options)
lp->GetLogger("NoopLoggerWithOptions", "options");
}

// Test the Log() overloads
TEST(Logger, LogMethodOverloads)
{
Expand Down Expand Up @@ -98,13 +84,6 @@ class TestProvider : public LoggerProvider
{
return shared_ptr<Logger>(new TestLogger());
}

shared_ptr<Logger> GetLogger(string_view library_name,
span<string_view> args,
nostd::string_view schema_url = "") override
{
return shared_ptr<Logger>(new TestLogger());
}
};

TEST(Logger, PushLoggerImplementation)
Expand Down
16 changes: 1 addition & 15 deletions api/test/logs/provider_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ class TestProvider : public LoggerProvider
{
return shared_ptr<Logger>(nullptr);
}

shared_ptr<Logger> GetLogger(string_view library_name,
span<string_view> args,
string_view schema_url = "") override
{
return shared_ptr<Logger>(nullptr);
}
};

TEST(Provider, GetLoggerProviderDefault)
Expand Down Expand Up @@ -61,16 +54,9 @@ TEST(Provider, MultipleLoggerProviders)
TEST(Provider, GetLogger)
{
auto tf = shared_ptr<LoggerProvider>(new TestProvider());
// tests GetLogger(name, options)
// tests GetLogger(name, version, schema)
const std::string schema_url{"https://opentelemetry.io/schemas/1.2.0"};
auto logger = tf->GetLogger("logger1", "", schema_url);
EXPECT_EQ(nullptr, logger);

// tests GetLogger(name, arguments)

std::array<string_view, 1> sv{"string"};
span<string_view> args{sv};
auto logger2 = tf->GetLogger("logger2", args, schema_url);
EXPECT_EQ(nullptr, logger2);
}
#endif
10 changes: 1 addition & 9 deletions exporters/etw/include/opentelemetry/exporters/etw/etw_logger.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -224,22 +224,14 @@ class LoggerProvider : public opentelemetry::logs::LoggerProvider
*/
nostd::shared_ptr<opentelemetry::logs::Logger> GetLogger(
nostd::string_view name,
nostd::string_view args = "",
nostd::string_view version = "",
nostd::string_view schema_url = "") override
{
UNREFERENCED_PARAMETER(args);
ETWProvider::EventFormat evtFmt = config_.encoding;
return nostd::shared_ptr<opentelemetry::logs::Logger>{new (std::nothrow)
etw::Logger(*this, name, evtFmt)};
}

nostd::shared_ptr<opentelemetry::logs::Logger> GetLogger(
nostd::string_view name,
nostd::span<nostd::string_view> args,
nostd::string_view schema_url = "") override
{
return GetLogger(name, args[0], schema_url);
}
};

} // namespace etw
Expand Down
17 changes: 2 additions & 15 deletions sdk/include/opentelemetry/sdk/logs/logger_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,13 @@ class LoggerProvider final : public opentelemetry::logs::LoggerProvider,
* Creates a logger with the given name, and returns a shared pointer to it.
* If a logger with that name already exists, return a shared pointer to it
* @param name The name of the logger to be created.
* @param options (OPTIONAL) The options for the logger. TODO: Once the logging spec defines it,
* give a list of options that the logger supports.
* @param version The version of the library.
*/
opentelemetry::nostd::shared_ptr<opentelemetry::logs::Logger> GetLogger(
opentelemetry::nostd::string_view name,
opentelemetry::nostd::string_view options = "",
opentelemetry::nostd::string_view version = "",
nostd::string_view schema_url = "") noexcept override;

/**
* Creates a logger with the given name, and returns a shared pointer to it.
* If a logger with that name already exists, return a shared pointer to it
* @param name The name of the logger to be created.
* @param args (OPTIONAL) The arguments for the logger. TODO: Once the logging spec defines it,
* give a list of arguments that the logger supports.
*/
opentelemetry::nostd::shared_ptr<opentelemetry::logs::Logger> GetLogger(
opentelemetry::nostd::string_view name,
nostd::span<nostd::string_view> args,
nostd::string_view schema_url = "") noexcept override;

/**
* Returns a shared pointer to the processor currently stored in the
* logger provider. If no processor exists, returns a nullptr
Expand Down
13 changes: 2 additions & 11 deletions sdk/src/logs/logger_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ LoggerProvider::LoggerProvider() noexcept : processor_{nullptr} {}

nostd::shared_ptr<logs_api::Logger> LoggerProvider::GetLogger(
nostd::string_view name,
nostd::string_view options,
nostd::string_view version,
nostd::string_view schema_url) noexcept
{
// Ensure only one thread can read/write from the map of loggers
Expand Down Expand Up @@ -46,22 +46,13 @@ nostd::shared_ptr<logs_api::Logger> LoggerProvider::GetLogger(

// If no logger with that name exists yet, create it and add it to the map of loggers

auto lib = instrumentationlibrary::InstrumentationLibrary::Create(name, name, schema_url);
auto lib = instrumentationlibrary::InstrumentationLibrary::Create(name, version, schema_url);
nostd::shared_ptr<logs_api::Logger> logger(
new Logger(name, this->shared_from_this(), std::move(lib)));
loggers_[name.data()] = logger;
return logger;
}

nostd::shared_ptr<logs_api::Logger> LoggerProvider::GetLogger(
nostd::string_view name,
nostd::span<nostd::string_view> args,
nostd::string_view schema_url) noexcept
{
// Currently, no args support
return GetLogger(name, "", schema_url);
}

std::shared_ptr<LogProcessor> LoggerProvider::GetProcessor() noexcept
{
return processor_.load();
Expand Down
16 changes: 0 additions & 16 deletions sdk/test/logs/logger_provider_sdk_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,6 @@ TEST(LoggerProviderSDK, LoggerProviderGetLoggerSimple)
ASSERT_EQ(logger1, logger3);
}

TEST(LoggerProviderSDK, LoggerProviderLoggerArguments)
{
// Currently, arguments are not supported by the loggers.
// TODO: Once the logging spec defines what arguments are allowed, add more
// detail to this test
nostd::string_view schema_url{"https://opentelemetry.io/schemas/1.2.0"};
auto lp = std::shared_ptr<logs_api::LoggerProvider>(new LoggerProvider());

auto logger1 = lp->GetLogger("logger1", "", schema_url);

// Check GetLogger(logger_name, args)
std::array<nostd::string_view, 1> sv{"string"};
nostd::span<nostd::string_view> args{sv};
auto logger2 = lp->GetLogger("logger2", args, schema_url);
}

class DummyProcessor : public LogProcessor
{
std::unique_ptr<Recordable> MakeRecordable() noexcept
Expand Down

0 comments on commit a74d784

Please sign in to comment.