diff options
67 files changed, 180 insertions, 146 deletions
diff --git a/config/src/apps/vespa-get-config/getconfig.cpp b/config/src/apps/vespa-get-config/getconfig.cpp index 74380390095..03a049044ae 100644 --- a/config/src/apps/vespa-get-config/getconfig.cpp +++ b/config/src/apps/vespa-get-config/getconfig.cpp @@ -12,6 +12,7 @@ #include <vespa/config/common/configresponse.h> #include <vespa/config/common/trace.h> #include <vespa/vespalib/util/signalhandler.h> +#include <cinttypes> #include <unistd.h> #include <sstream> diff --git a/config/src/tests/functiontest/functiontest.cpp b/config/src/tests/functiontest/functiontest.cpp index 333645176a0..9d6605be9c1 100644 --- a/config/src/tests/functiontest/functiontest.cpp +++ b/config/src/tests/functiontest/functiontest.cpp @@ -7,6 +7,7 @@ #include <vespa/vespalib/data/slime/slime.h> #include <vespa/vespalib/testkit/test_kit.h> #include <fstream> +#include <cinttypes> #include <vespa/log/log.h> diff --git a/config/src/vespa/config/frt/frtconfigagent.cpp b/config/src/vespa/config/frt/frtconfigagent.cpp index b5bcb3591f0..15b605ad690 100644 --- a/config/src/vespa/config/frt/frtconfigagent.cpp +++ b/config/src/vespa/config/frt/frtconfigagent.cpp @@ -4,6 +4,7 @@ #include <vespa/config/common/trace.h> #include <vespa/config/common/configresponse.h> #include <vespa/config/common/iconfigholder.h> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".config.frt.frtconfigagent"); diff --git a/config/src/vespa/config/set/configsetsource.cpp b/config/src/vespa/config/set/configsetsource.cpp index 41886a12d01..b84f6411855 100644 --- a/config/src/vespa/config/set/configsetsource.cpp +++ b/config/src/vespa/config/set/configsetsource.cpp @@ -4,6 +4,7 @@ #include <vespa/config/print/asciiconfigwriter.h> #include <vespa/config/common/iconfigholder.h> #include <vespa/config/common/exceptions.h> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".config.set.configsetsource"); diff --git a/config/src/vespa/config/subscription/configsubscriptionset.cpp b/config/src/vespa/config/subscription/configsubscriptionset.cpp index 4f7bf64f603..9c09a508fff 100644 --- a/config/src/vespa/config/subscription/configsubscriptionset.cpp +++ b/config/src/vespa/config/subscription/configsubscriptionset.cpp @@ -6,6 +6,7 @@ #include <vespa/config/common/misc.h> #include <vespa/config/common/iconfigmanager.h> #include <vespa/config/common/iconfigcontext.h> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".config.subscription.configsubscriptionset"); diff --git a/configd/src/apps/sentinel/config-owner.cpp b/configd/src/apps/sentinel/config-owner.cpp index 90ceb705dc7..1fe361ef739 100644 --- a/configd/src/apps/sentinel/config-owner.cpp +++ b/configd/src/apps/sentinel/config-owner.cpp @@ -2,6 +2,7 @@ #include "config-owner.h" #include <vespa/config/subscription/configsubscriber.hpp> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".sentinel.config-owner"); @@ -9,7 +10,6 @@ LOG_SETUP(".sentinel.config-owner"); namespace config::sentinel { ConfigOwner::ConfigOwner() = default; - ConfigOwner::~ConfigOwner() = default; void diff --git a/configd/src/apps/sentinel/logctl.cpp b/configd/src/apps/sentinel/logctl.cpp index 94759d4f102..057178cec2e 100644 --- a/configd/src/apps/sentinel/logctl.cpp +++ b/configd/src/apps/sentinel/logctl.cpp @@ -5,7 +5,7 @@ #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> -#include <stdio.h> +#include <cstring> #include <vespa/log/log.h> LOG_SETUP(".sentinel.logctl"); diff --git a/configd/src/apps/sentinel/model-owner.cpp b/configd/src/apps/sentinel/model-owner.cpp index 5dd7a033933..93024911f4e 100644 --- a/configd/src/apps/sentinel/model-owner.cpp +++ b/configd/src/apps/sentinel/model-owner.cpp @@ -3,6 +3,7 @@ #include "model-owner.h" #include <vespa/config/common/exceptions.h> #include <vespa/config/subscription/configsubscriber.hpp> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".sentinel.model-owner"); diff --git a/logd/src/logd/watcher.cpp b/logd/src/logd/watcher.cpp index c3752fcc3e8..af1efc3077d 100644 --- a/logd/src/logd/watcher.cpp +++ b/logd/src/logd/watcher.cpp @@ -8,6 +8,7 @@ #include <vespa/vespalib/util/time.h> #include <vespa/vespalib/util/size_literals.h> #include <thread> +#include <cinttypes> #include <fcntl.h> #include <glob.h> #include <sys/stat.h> diff --git a/messagebus/src/tests/sequencer/sequencer.cpp b/messagebus/src/tests/sequencer/sequencer.cpp index 25d9934fe8d..7a3aaab9b1f 100644 --- a/messagebus/src/tests/sequencer/sequencer.cpp +++ b/messagebus/src/tests/sequencer/sequencer.cpp @@ -5,6 +5,7 @@ #include <vespa/messagebus/routablequeue.h> #include <vespa/messagebus/emptyreply.h> #include <vespa/vespalib/testkit/testapp.h> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP("sequencer_test"); diff --git a/searchcore/src/tests/proton/attribute/attributeflush_test.cpp b/searchcore/src/tests/proton/attribute/attributeflush_test.cpp index b94df75c7be..a10fec131e0 100644 --- a/searchcore/src/tests/proton/attribute/attributeflush_test.cpp +++ b/searchcore/src/tests/proton/attribute/attributeflush_test.cpp @@ -23,6 +23,7 @@ #include <vespa/vespalib/util/threadstackexecutor.h> #include <filesystem> #include <thread> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP("attributeflush_test"); diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp index 16be2c1bd25..d39d2873edb 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_initializer.cpp @@ -14,6 +14,7 @@ #include <vespa/searchlib/attribute/attribute_header.h> #include <vespa/searchlib/attribute/attributevector.h> #include <vespa/fastos/file.h> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".proton.attribute.attribute_initializer"); diff --git a/searchcore/src/vespa/searchcore/proton/index/index_writer.cpp b/searchcore/src/vespa/searchcore/proton/index/index_writer.cpp index 3512d2eebad..2c26b043fad 100644 --- a/searchcore/src/vespa/searchcore/proton/index/index_writer.cpp +++ b/searchcore/src/vespa/searchcore/proton/index/index_writer.cpp @@ -2,6 +2,7 @@ #include "index_writer.h" #include <vespa/document/fieldvalue/document.h> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".proton.server.indexadapter"); diff --git a/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp b/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp index 7ee6a02d03e..e4a4e6761aa 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp @@ -21,6 +21,7 @@ #include <filesystem> #include <sstream> #include <cassert> +#include <cinttypes> #include <fcntl.h> #include <vespa/log/log.h> diff --git a/searchcore/src/vespa/searchcore/proton/server/memory_flush_config_updater.cpp b/searchcore/src/vespa/searchcore/proton/server/memory_flush_config_updater.cpp index 50a499c8a73..3222cbc3a06 100644 --- a/searchcore/src/vespa/searchcore/proton/server/memory_flush_config_updater.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/memory_flush_config_updater.cpp @@ -2,6 +2,7 @@ #include "memory_flush_config_updater.h" #include <vespa/vespalib/util/size_literals.h> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".proton.server.memory_flush_config_updater"); diff --git a/searchcore/src/vespa/searchcore/proton/server/memoryflush.cpp b/searchcore/src/vespa/searchcore/proton/server/memoryflush.cpp index f8d7519fd0c..fbc6e2beaf5 100644 --- a/searchcore/src/vespa/searchcore/proton/server/memoryflush.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/memoryflush.cpp @@ -7,6 +7,7 @@ #include <vespa/vespalib/stllike/hash_set.h> #include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/time.h> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".proton.server.memoryflush"); diff --git a/searchcore/src/vespa/searchcore/proton/server/simpleflush.cpp b/searchcore/src/vespa/searchcore/proton/server/simpleflush.cpp index a1234ccc8fc..4de426b56d1 100644 --- a/searchcore/src/vespa/searchcore/proton/server/simpleflush.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/simpleflush.cpp @@ -2,15 +2,14 @@ #include "simpleflush.h" #include <algorithm> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".proton.server.simpleflush"); namespace proton { -SimpleFlush::SimpleFlush() -{ -} +SimpleFlush::SimpleFlush() = default; FlushContext::List SimpleFlush::getFlushTargets(const FlushContext::List& targetList, diff --git a/searchcore/src/vespa/searchcore/proton/server/summaryadapter.cpp b/searchcore/src/vespa/searchcore/proton/server/summaryadapter.cpp index 038af801b80..b4565003e9e 100644 --- a/searchcore/src/vespa/searchcore/proton/server/summaryadapter.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/summaryadapter.cpp @@ -4,6 +4,7 @@ #include <vespa/searchcore/proton/docsummary/summarymanager.h> #include <vespa/vespalib/objects/nbostream.h> #include <cassert> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".proton.server.summaryadapter"); diff --git a/searchcore/src/vespa/searchcorespi/index/indexflushtarget.cpp b/searchcore/src/vespa/searchcorespi/index/indexflushtarget.cpp index e72525d0aaa..53fb21bf1ed 100644 --- a/searchcore/src/vespa/searchcorespi/index/indexflushtarget.cpp +++ b/searchcore/src/vespa/searchcorespi/index/indexflushtarget.cpp @@ -2,6 +2,7 @@ #include "indexflushtarget.h" #include <vespa/vespalib/util/size_literals.h> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".searchcorespi.index.indexflushtarget"); diff --git a/searchcore/src/vespa/searchcorespi/index/indexfusiontarget.cpp b/searchcore/src/vespa/searchcorespi/index/indexfusiontarget.cpp index 1df6d321f99..6755976939b 100644 --- a/searchcore/src/vespa/searchcorespi/index/indexfusiontarget.cpp +++ b/searchcore/src/vespa/searchcorespi/index/indexfusiontarget.cpp @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "indexfusiontarget.h" +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".searchcorespi.index.indexfusiontarget"); diff --git a/searchlib/src/apps/uniform/uniform.cpp b/searchlib/src/apps/uniform/uniform.cpp index 784c69f4647..807b8d61a9e 100644 --- a/searchlib/src/apps/uniform/uniform.cpp +++ b/searchlib/src/apps/uniform/uniform.cpp @@ -2,8 +2,7 @@ #include <vespa/vespalib/util/signalhandler.h> #include <vespa/searchlib/bitcompression/compression.h> -#include <vespa/log/log.h> - +#include <cinttypes> static uint64_t maxExpGolombVal(uint64_t kValue, uint64_t maxBits) diff --git a/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp b/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp index a5d950c0f31..6278b216b52 100644 --- a/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp +++ b/searchlib/src/apps/vespa-index-inspect/vespa-index-inspect.cpp @@ -16,6 +16,7 @@ #include <iostream> #include <getopt.h> #include <cstdlib> +#include <cinttypes> #include <unistd.h> #include <vespa/log/log.h> @@ -256,12 +257,12 @@ ShowPostingListSubApp::getOptions(int argc, char **argv) int c; int longopt_index = 0; static struct option longopts[] = { - { "indexdir", 1, NULL, 0 }, - { "field", 1, NULL, 0 }, - { "transpose", 0, NULL, 0 }, - { "docidlimit", 1, NULL, 0 }, - { "mindocid", 1, NULL, 0 }, - { NULL, 0, NULL, 0 } + { "indexdir", 1, nullptr, 0 }, + { "field", 1, nullptr, 0 }, + { "transpose", 0, nullptr, 0 }, + { "docidlimit", 1, nullptr, 0 }, + { "mindocid", 1, nullptr, 0 }, + { nullptr, 0, nullptr, 0 } }; enum longopts_enum { LONGOPT_INDEXDIR, @@ -293,7 +294,7 @@ ShowPostingListSubApp::getOptions(int argc, char **argv) _minDocId = atoi(optarg); break; default: - if (optarg != NULL) { + if (optarg != nullptr) { LOG(error, "longopt %s with arg %s", longopts[longopt_index].name, optarg); @@ -683,9 +684,7 @@ DumpWordsSubApp::DumpWordsSubApp() } -DumpWordsSubApp::~DumpWordsSubApp() -{ -} +DumpWordsSubApp::~DumpWordsSubApp() = default; void @@ -708,12 +707,12 @@ DumpWordsSubApp::getOptions(int argc, char **argv) int c; int longopt_index = 0; static struct option longopts[] = { - { "indexdir", 1, NULL, 0 }, - { "field", 1, NULL, 0 }, - { "minnumdocs", 1, NULL, 0 }, - { "verbose", 0, NULL, 0 }, - { "wordnum", 0, NULL, 0 }, - { NULL, 0, NULL, 0 } + { "indexdir", 1, nullptr, 0 }, + { "field", 1, nullptr, 0 }, + { "minnumdocs", 1, nullptr, 0 }, + { "verbose", 0, nullptr, 0 }, + { "wordnum", 0, nullptr, 0 }, + { nullptr, 0, nullptr, 0 } }; enum longopts_enum { LONGOPT_INDEXDIR, @@ -745,7 +744,7 @@ DumpWordsSubApp::getOptions(int argc, char **argv) _showWordNum = true; break; default: - if (optarg != NULL) { + if (optarg != nullptr) { LOG(error, "longopt %s with arg %s", longopts[longopt_index].name, optarg); diff --git a/searchlib/src/tests/attribute/postinglist/postinglist.cpp b/searchlib/src/tests/attribute/postinglist/postinglist.cpp index 3f07faa159f..7d2a89b6e5b 100644 --- a/searchlib/src/tests/attribute/postinglist/postinglist.cpp +++ b/searchlib/src/tests/attribute/postinglist/postinglist.cpp @@ -11,6 +11,7 @@ #include <vespa/vespalib/testkit/testapp.h> #include <set> #include <map> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP("postinglist_test"); diff --git a/searchlib/src/tests/attribute/reference_attribute/reference_attribute_test.cpp b/searchlib/src/tests/attribute/reference_attribute/reference_attribute_test.cpp index b5101f1ea58..e356187a19f 100644 --- a/searchlib/src/tests/attribute/reference_attribute/reference_attribute_test.cpp +++ b/searchlib/src/tests/attribute/reference_attribute/reference_attribute_test.cpp @@ -15,6 +15,7 @@ #include <vespa/vespalib/gtest/gtest.h> #include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/test/insertion_operators.h> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP("reference_attribute_test"); diff --git a/searchlib/src/tests/bitcompression/expgolomb/expgolomb_test.cpp b/searchlib/src/tests/bitcompression/expgolomb/expgolomb_test.cpp index 5bb36a8462e..9a726f9d8a6 100644 --- a/searchlib/src/tests/bitcompression/expgolomb/expgolomb_test.cpp +++ b/searchlib/src/tests/bitcompression/expgolomb/expgolomb_test.cpp @@ -5,6 +5,7 @@ #include <vespa/vespalib/util/size_literals.h> #include <vector> #include <algorithm> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP("expglomb_test"); diff --git a/searchlib/src/tests/common/location_iterator/location_iterator_test.cpp b/searchlib/src/tests/common/location_iterator/location_iterator_test.cpp index 44a2f1697cd..bf372c0e62f 100644 --- a/searchlib/src/tests/common/location_iterator/location_iterator_test.cpp +++ b/searchlib/src/tests/common/location_iterator/location_iterator_test.cpp @@ -9,6 +9,7 @@ #include <vespa/searchlib/common/locationiterators.h> #include <vespa/searchcommon/attribute/config.h> #include <vespa/vespalib/gtest/gtest.h> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP("location_iterator_test"); diff --git a/searchlib/src/tests/diskindex/pagedict4/pagedict4test.cpp b/searchlib/src/tests/diskindex/pagedict4/pagedict4test.cpp index f1729f21f39..408cf370c59 100644 --- a/searchlib/src/tests/diskindex/pagedict4/pagedict4test.cpp +++ b/searchlib/src/tests/diskindex/pagedict4/pagedict4test.cpp @@ -16,6 +16,7 @@ #include <vespa/searchlib/common/tunefileinfo.h> #include <vespa/vespalib/util/signalhandler.h> #include <sstream> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP("pagedict4test"); diff --git a/searchlib/src/tests/memoryindex/datastore/feature_store_test.cpp b/searchlib/src/tests/memoryindex/datastore/feature_store_test.cpp index 564824031a6..f4dda88b6f0 100644 --- a/searchlib/src/tests/memoryindex/datastore/feature_store_test.cpp +++ b/searchlib/src/tests/memoryindex/datastore/feature_store_test.cpp @@ -3,6 +3,7 @@ #include <vespa/searchlib/memoryindex/feature_store.h> #include <vespa/searchcommon/common/schema.h> #include <vespa/vespalib/gtest/gtest.h> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP("feature_store_test"); diff --git a/searchlib/src/tests/sortspec/multilevelsort.cpp b/searchlib/src/tests/sortspec/multilevelsort.cpp index ec14f0c97e1..001903ff302 100644 --- a/searchlib/src/tests/sortspec/multilevelsort.cpp +++ b/searchlib/src/tests/sortspec/multilevelsort.cpp @@ -11,6 +11,7 @@ #include <vespa/vespalib/util/testclock.h> #include <vespa/vespalib/testkit/testapp.h> #include <type_traits> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP("multilevelsort_test"); diff --git a/searchlib/src/vespa/searchlib/common/bitvectorcache.cpp b/searchlib/src/vespa/searchlib/common/bitvectorcache.cpp index cb4d112b77e..8bb24bcbbec 100644 --- a/searchlib/src/vespa/searchlib/common/bitvectorcache.cpp +++ b/searchlib/src/vespa/searchlib/common/bitvectorcache.cpp @@ -3,6 +3,7 @@ #include <vespa/vespalib/stllike/hash_map.hpp> #include <algorithm> #include <cassert> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".searchlib.common.bitvectorcache"); diff --git a/searchlib/src/vespa/searchlib/diskindex/fileheader.cpp b/searchlib/src/vespa/searchlib/diskindex/fileheader.cpp index e1c31c1ed8d..5399d70fbe7 100644 --- a/searchlib/src/vespa/searchlib/diskindex/fileheader.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/fileheader.cpp @@ -5,6 +5,7 @@ #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/data/fileheader.h> #include <vespa/fastos/file.h> +#include <cinttypes> #include <arpa/inet.h> #include <vespa/log/log.h> diff --git a/searchlib/src/vespa/searchlib/docstore/compacter.cpp b/searchlib/src/vespa/searchlib/docstore/compacter.cpp index 04ff150c741..c886e52659f 100644 --- a/searchlib/src/vespa/searchlib/docstore/compacter.cpp +++ b/searchlib/src/vespa/searchlib/docstore/compacter.cpp @@ -4,6 +4,7 @@ #include "logdatastore.h" #include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/array.hpp> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".searchlib.docstore.compacter"); diff --git a/searchlib/src/vespa/searchlib/engine/proto_converter.cpp b/searchlib/src/vespa/searchlib/engine/proto_converter.cpp index ae00889850b..b03dbf5ff37 100644 --- a/searchlib/src/vespa/searchlib/engine/proto_converter.cpp +++ b/searchlib/src/vespa/searchlib/engine/proto_converter.cpp @@ -6,8 +6,9 @@ #include <vespa/vespalib/data/slime/binary_format.h> #include <vespa/vespalib/data/smart_buffer.h> #include <vespa/vespalib/util/size_literals.h> -#include <vespa/log/log.h> +#include <cinttypes> +#include <vespa/log/log.h> LOG_SETUP(".searchlib.engine.proto_converter"); namespace search::engine { diff --git a/searchlib/src/vespa/searchlib/features/random_normal_feature.cpp b/searchlib/src/vespa/searchlib/features/random_normal_feature.cpp index 91ccd390692..ad92f8ef6e0 100644 --- a/searchlib/src/vespa/searchlib/features/random_normal_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/random_normal_feature.cpp @@ -5,6 +5,7 @@ #include <vespa/searchlib/fef/properties.h> #include <vespa/vespalib/util/stash.h> #include <chrono> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".features.randomnormalfeature"); diff --git a/searchlib/src/vespa/searchlib/features/random_normal_stable_feature.cpp b/searchlib/src/vespa/searchlib/features/random_normal_stable_feature.cpp index f7fcffca8cb..f1a42da1266 100644 --- a/searchlib/src/vespa/searchlib/features/random_normal_stable_feature.cpp +++ b/searchlib/src/vespa/searchlib/features/random_normal_stable_feature.cpp @@ -4,6 +4,7 @@ #include "utils.h" #include <vespa/searchlib/fef/properties.h> #include <vespa/vespalib/util/stash.h> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".features.randomnormalstablefeature"); diff --git a/searchlib/src/vespa/searchlib/features/randomfeature.cpp b/searchlib/src/vespa/searchlib/features/randomfeature.cpp index a8f2dd275a7..30a313d54d2 100644 --- a/searchlib/src/vespa/searchlib/features/randomfeature.cpp +++ b/searchlib/src/vespa/searchlib/features/randomfeature.cpp @@ -5,6 +5,7 @@ #include <vespa/searchlib/fef/properties.h> #include <vespa/vespalib/util/stash.h> #include <chrono> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".features.randomfeature"); diff --git a/searchlib/src/vespa/searchlib/predicate/predicate_range_term_expander.h b/searchlib/src/vespa/searchlib/predicate/predicate_range_term_expander.h index 42de8646091..6a6b91e20f2 100644 --- a/searchlib/src/vespa/searchlib/predicate/predicate_range_term_expander.h +++ b/searchlib/src/vespa/searchlib/predicate/predicate_range_term_expander.h @@ -5,6 +5,7 @@ #include <vespa/vespalib/stllike/string.h> #include <vespa/vespalib/util/issue.h> #include <climits> +#include <cinttypes> namespace search::predicate { diff --git a/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.cpp b/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.cpp index e3cf067bd49..6bba9d96d02 100644 --- a/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.cpp +++ b/searchlib/src/vespa/searchlib/test/fakedata/fakeegcompr64filterocc.cpp @@ -5,6 +5,7 @@ #include "bitdecode64.h" #include "fpfactory.h" #include <vespa/searchlib/queryeval/iterators.h> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".searchlib.test.fake_eg_compr64_filter_occ"); diff --git a/searchlib/src/vespa/searchlib/transactionlog/session.cpp b/searchlib/src/vespa/searchlib/transactionlog/session.cpp index b11f4027ae7..ec77a5f150e 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/session.cpp +++ b/searchlib/src/vespa/searchlib/transactionlog/session.cpp @@ -4,6 +4,7 @@ #include "domainpart.h" #include <vespa/fastlib/io/bufferedfile.h> #include <cassert> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".transactionlog.session"); diff --git a/searchlib/src/vespa/searchlib/util/filesizecalculator.cpp b/searchlib/src/vespa/searchlib/util/filesizecalculator.cpp index 16a96c7b439..c50d402db0e 100644 --- a/searchlib/src/vespa/searchlib/util/filesizecalculator.cpp +++ b/searchlib/src/vespa/searchlib/util/filesizecalculator.cpp @@ -2,6 +2,7 @@ #include "filesizecalculator.h" #include <vespa/vespalib/data/fileheader.h> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".searchlib.util.filesizecalculator"); diff --git a/searchlib/src/vespa/searchlib/util/url.cpp b/searchlib/src/vespa/searchlib/util/url.cpp index 5eeb16e3f3b..141f54363e9 100644 --- a/searchlib/src/vespa/searchlib/util/url.cpp +++ b/searchlib/src/vespa/searchlib/util/url.cpp @@ -3,6 +3,7 @@ #include "url.h" #include <algorithm> #include <cstdio> +#include <cstring> #include <vespa/log/log.h> LOG_SETUP(".searchlib.util.url"); diff --git a/searchsummary/src/vespa/juniper/Matcher.cpp b/searchsummary/src/vespa/juniper/Matcher.cpp index 22d1bbc7e96..73362aac5a3 100644 --- a/searchsummary/src/vespa/juniper/Matcher.cpp +++ b/searchsummary/src/vespa/juniper/Matcher.cpp @@ -1,7 +1,5 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <algorithm> -#include <string> #include "query.h" #include "juniperdebug.h" #include "sumdesc.h" @@ -10,6 +8,10 @@ #include "juniperparams.h" #include "config.h" #include <sstream> +#include <algorithm> +#include <string> +#include <cinttypes> + #include <vespa/log/log.h> LOG_SETUP(".juniper.matcher"); diff --git a/searchsummary/src/vespa/juniper/sumdesc.cpp b/searchsummary/src/vespa/juniper/sumdesc.cpp index 18e1b7bbd11..aa6aededa0c 100644 --- a/searchsummary/src/vespa/juniper/sumdesc.cpp +++ b/searchsummary/src/vespa/juniper/sumdesc.cpp @@ -6,6 +6,7 @@ #include "Matcher.h" #include "appender.h" #include <vespa/fastlib/text/unicodeutil.h> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".juniper.sumdesc"); diff --git a/searchsummary/src/vespa/juniper/tokenizer.cpp b/searchsummary/src/vespa/juniper/tokenizer.cpp index 1b58be2d451..965befe01e3 100644 --- a/searchsummary/src/vespa/juniper/tokenizer.cpp +++ b/searchsummary/src/vespa/juniper/tokenizer.cpp @@ -3,6 +3,7 @@ #include "tokenizer.h" #include "juniperdebug.h" #include <vespa/fastlib/text/wordfolder.h> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".juniper.tokenizer"); diff --git a/storage/src/vespa/storage/distributor/messagetracker.cpp b/storage/src/vespa/storage/distributor/messagetracker.cpp index 93db31bdc29..8830e5ecabc 100644 --- a/storage/src/vespa/storage/distributor/messagetracker.cpp +++ b/storage/src/vespa/storage/distributor/messagetracker.cpp @@ -3,6 +3,7 @@ #include "messagetracker.h" #include <vespa/storageapi/messageapi/bucketcommand.h> #include <vespa/storageapi/messageapi/bucketreply.h> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".messagetracker"); diff --git a/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp b/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp index 55fe2e039e1..bdf4fa2ba72 100644 --- a/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp +++ b/storage/src/vespa/storage/distributor/operations/external/twophaseupdateoperation.cpp @@ -12,7 +12,7 @@ #include <vespa/storage/distributor/distributor_bucket_space_repo.h> #include <vespa/storageapi/message/persistence.h> #include <vespa/vdslib/state/cluster_state_bundle.h> -#include <vespa/vespalib/stllike/hash_map.hpp> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".distributor.callback.twophaseupdate"); diff --git a/storage/src/vespa/storage/distributor/sentmessagemap.cpp b/storage/src/vespa/storage/distributor/sentmessagemap.cpp index 44dd4fbde89..4b7292c1e81 100644 --- a/storage/src/vespa/storage/distributor/sentmessagemap.cpp +++ b/storage/src/vespa/storage/distributor/sentmessagemap.cpp @@ -4,6 +4,7 @@ #include <vespa/storage/distributor/operations/operation.h> #include <sstream> #include <set> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP(".distributor.callback.map"); diff --git a/storage/src/vespa/storageframework/defaultimplementation/thread/threadimpl.cpp b/storage/src/vespa/storageframework/defaultimplementation/thread/threadimpl.cpp index 314434a4c1a..c1fa2aac708 100644 --- a/storage/src/vespa/storageframework/defaultimplementation/thread/threadimpl.cpp +++ b/storage/src/vespa/storageframework/defaultimplementation/thread/threadimpl.cpp @@ -5,6 +5,7 @@ #include <vespa/storageframework/generic/clock/clock.h> #include <vespa/vespalib/util/atomic.h> #include <vespa/vespalib/util/signalhandler.h> +#include <cinttypes> #include <vespa/log/bufferedlogger.h> LOG_SETUP(".framework.thread.impl"); diff --git a/vespalib/src/tests/btree/iteratespeed.cpp b/vespalib/src/tests/btree/iteratespeed.cpp index fceaf01a785..48c4b4a1c39 100644 --- a/vespalib/src/tests/btree/iteratespeed.cpp +++ b/vespalib/src/tests/btree/iteratespeed.cpp @@ -1,10 +1,8 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/vespalib/btree/btreeroot.h> #include <vespa/vespalib/btree/btreebuilder.h> #include <vespa/vespalib/btree/btreenodeallocator.h> #include <vespa/vespalib/btree/btree.h> -#include <vespa/vespalib/btree/btreestore.h> #include <vespa/vespalib/btree/btreenodeallocator.hpp> #include <vespa/vespalib/btree/btreenode.hpp> #include <vespa/vespalib/btree/btreenodestore.hpp> @@ -12,11 +10,10 @@ #include <vespa/vespalib/btree/btreeroot.hpp> #include <vespa/vespalib/btree/btreebuilder.hpp> #include <vespa/vespalib/btree/btree.hpp> -#include <vespa/vespalib/btree/btreestore.hpp> #include <vespa/vespalib/datastore/buffer_type.hpp> #include <vespa/vespalib/util/rand48.h> #include <vespa/vespalib/util/time.h> - +#include <cinttypes> #include <unistd.h> #include <vespa/log/log.h> diff --git a/vespalib/src/tests/datastore/datastore/datastore_test.cpp b/vespalib/src/tests/datastore/datastore/datastore_test.cpp index 645871d3ef6..e17ac94775e 100644 --- a/vespalib/src/tests/datastore/datastore/datastore_test.cpp +++ b/vespalib/src/tests/datastore/datastore/datastore_test.cpp @@ -6,6 +6,7 @@ #include <vespa/vespalib/test/insertion_operators.h> #include <vespa/vespalib/test/memory_allocator_observer.h> #include <vespa/vespalib/util/size_literals.h> +#include <cinttypes> #include <vespa/log/log.h> LOG_SETUP("datastore_test"); diff --git a/vespalib/src/tests/util/generationhandler_stress/generation_handler_stress_test.cpp b/vespalib/src/tests/util/generationhandler_stress/generation_handler_stress_test.cpp index 1cc54da7f2e..4abae54e06f 100644 --- a/vespalib/src/tests/util/generationhandler_stress/generation_handler_stress_test.cpp +++ b/vespalib/src/tests/util/generationhandler_stress/generation_handler_stress_test.cpp @@ -1,12 +1,15 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/log/log.h> -LOG_SETUP("generation_handler_stress_test"); + #include <vespa/vespalib/gtest/gtest.h> #include <vespa/vespalib/util/generationhandler.h> #include <vespa/vespalib/util/lambdatask.h> #include <vespa/vespalib/util/threadstackexecutor.h> #include <vespa/vespalib/util/size_literals.h> #include <thread> +#include <cinttypes> + +#include <vespa/log/log.h> +LOG_SETUP("generation_handler_stress_test"); using vespalib::Executor; using vespalib::GenerationHandler; diff --git a/vespalib/src/vespa/vespalib/data/slime/json_format.cpp b/vespalib/src/vespa/vespalib/data/slime/json_format.cpp index 2681ba6f52b..9cda8a7fae1 100644 --- a/vespalib/src/vespa/vespalib/data/slime/json_format.cpp +++ b/vespalib/src/vespa/vespalib/data/slime/json_format.cpp @@ -7,6 +7,7 @@ #include <vespa/vespalib/data/memory_input.h> #include <vespa/vespalib/locale/c.h> #include <cmath> +#include <cinttypes> #include <sstream> #include <cassert> diff --git a/vespalib/src/vespa/vespalib/net/native_epoll.cpp b/vespalib/src/vespa/vespalib/net/native_epoll.cpp index 1e68826a145..8b73b092ab2 100644 --- a/vespalib/src/vespa/vespalib/net/native_epoll.cpp +++ b/vespalib/src/vespa/vespalib/net/native_epoll.cpp @@ -3,6 +3,7 @@ #include "native_epoll.h" #include <cassert> #include <cerrno> +#include <cstring> #include <unistd.h> #include <vespa/log/log.h> diff --git a/vespalib/src/vespa/vespalib/util/process_memory_stats.cpp b/vespalib/src/vespa/vespalib/util/process_memory_stats.cpp index f7e8e087727..41f1e282c4b 100644 --- a/vespalib/src/vespa/vespalib/util/process_memory_stats.cpp +++ b/vespalib/src/vespa/vespalib/util/process_memory_stats.cpp @@ -4,6 +4,7 @@ #include <vespa/vespalib/stllike/asciistream.h> #include <algorithm> #include <vector> +#include <cinttypes> #include <vespa/log/log.h> diff --git a/vespalog/src/logctl/logctl.cpp b/vespalog/src/logctl/logctl.cpp index 4cf44e9cd22..9a8987fc462 100644 --- a/vespalog/src/logctl/logctl.cpp +++ b/vespalog/src/logctl/logctl.cpp @@ -6,6 +6,7 @@ #include <vespa/log/component.h> #include <optional> +#include <cstring> #include <unistd.h> #include <dirent.h> #include <sys/stat.h> @@ -16,7 +17,7 @@ LOG_SETUP("vespa-logctl"); using namespace ns_log; static void modifyLevels(const char *file, const char *component, const char *levels, - bool shouldCreateFile, bool shouldCreateEntry); + bool shouldCreateFile, bool shouldCreateEntry); static void readLevels(const char *file, const char *component); diff --git a/vespalog/src/logger/llreader.cpp b/vespalog/src/logger/llreader.cpp index cb25b6747bf..200f4bb039d 100644 --- a/vespalog/src/logger/llreader.cpp +++ b/vespalog/src/logger/llreader.cpp @@ -1,17 +1,12 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <stdlib.h> -#include <string.h> -#include <stdio.h> -#include <fcntl.h> -#include <errno.h> -#include <unistd.h> -#include <sys/time.h> #include "llreader.h" +#include <cstdlib> +#include <cstring> +#include <unistd.h> namespace ns_log { - InputBuf::InputBuf(int fd) : _inputfd(fd), _size(1000), diff --git a/vespalog/src/test/bufferedlogskiptest.cpp b/vespalog/src/test/bufferedlogskiptest.cpp index abb5705b612..29e5e119c34 100644 --- a/vespalog/src/test/bufferedlogskiptest.cpp +++ b/vespalog/src/test/bufferedlogskiptest.cpp @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/log/bufferedlogger.h> +#include <vespa/log/internal.h> #include <fstream> #include <iostream> @@ -15,7 +16,9 @@ using namespace std::literals::chrono_literals; struct TestTimer : public ns_log::Timer { uint64_t & _time; TestTimer(uint64_t & timeVar) : _time(timeVar) { } - ns_log::system_time getTimestamp() const override { return ns_log::system_time(std::chrono::microseconds(_time)); } + ns_log::system_time getTimestamp() const noexcept override { + return ns_log::system_time(std::chrono::microseconds(_time)); + } }; std::string readFile(const std::string& file) { @@ -71,8 +74,8 @@ void testSkipBufferOnDebug(const std::string& file, uint64_t & timer) void reset(uint64_t & timer) { timer = 0; ns_log::BufferedLogger::instance().setMaxCacheSize(10); - ns_log::BufferedLogger::instance().setMaxEntryAge(300s); - ns_log::BufferedLogger::instance().setCountFactor(5s); + ns_log::BufferedLogger::instance().setMaxEntryAge(300); + ns_log::BufferedLogger::instance().setCountFactor(5); } int diff --git a/vespalog/src/test/bufferedlogtest.cpp b/vespalog/src/test/bufferedlogtest.cpp index d3fc1c28d63..a2dfdd7c6b8 100644 --- a/vespalog/src/test/bufferedlogtest.cpp +++ b/vespalog/src/test/bufferedlogtest.cpp @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/log/bufferedlogger.h> +#include <vespa/log/internal.h> #include "bufferedlogtest.logger1.h" #include "bufferedlogtest.logger2.h" @@ -19,7 +20,9 @@ using namespace std::literals::chrono_literals; struct TestTimer : public ns_log::Timer { uint64_t & _time; TestTimer(uint64_t & timeVar) : _time(timeVar) { } - ns_log::system_time getTimestamp() const override { return ns_log::system_time(std::chrono::microseconds(_time)); } + ns_log::system_time getTimestamp() const noexcept override { + return ns_log::system_time(std::chrono::microseconds(_time)); + } }; std::string readFile(const std::string& file) { @@ -122,9 +125,9 @@ void testThatEntriesWithHighCountsAreEventuallyRemoved( // Should eventually throw out the entries with high count timer = 10 * 1000000 + 4; // Make sure we don't remove due to age. - ns_log::BufferedLogger::instance().setMaxEntryAge(1000000s); + ns_log::BufferedLogger::instance().setMaxEntryAge(1000000); // Let each count, count for 5 seconds. - ns_log::BufferedLogger::instance().setCountFactor(5s); + ns_log::BufferedLogger::instance().setCountFactor(5); LOGBM(info, "Starting up, using logfile %s", file.c_str()); timer = 100 * 1000000 + 4; @@ -157,9 +160,9 @@ void testThatEntriesExpire( // Test that we don't keep entries longer than max age timer = 10 * 1000000 + 4; // Time out after 120 seconds - ns_log::BufferedLogger::instance().setMaxEntryAge(120s); + ns_log::BufferedLogger::instance().setMaxEntryAge(120); // Let counts count much, so they expire due to time instead - ns_log::BufferedLogger::instance().setCountFactor(100000s); + ns_log::BufferedLogger::instance().setCountFactor(100000); LOGBM(info, "Starting up, using logfile %s", file.c_str()); timer = 100 * 1000000 + 4; @@ -227,9 +230,9 @@ void testThatHighCountEntriesDontStarveOthers( std::cerr << "testThatHighCountEntriesDontStarveOthers ...\n"; timer = 10 * 1000000 + 4; // Long time out, we don't want to rely on timeout to prevent starvation - ns_log::BufferedLogger::instance().setMaxEntryAge(12000000s); + ns_log::BufferedLogger::instance().setMaxEntryAge(12000000); // Let counts count much, so they score high - ns_log::BufferedLogger::instance().setCountFactor(100000s); + ns_log::BufferedLogger::instance().setCountFactor(100000); LOGBM(info, "Starting up, using logfile %s", file.c_str()); timer = 100 * 1000000; @@ -382,8 +385,8 @@ void testNonBufferedLoggerTriggersBufferedLogTrim(const std::string& file, void reset(uint64_t& timer) { timer = 0; - ns_log::BufferedLogger::instance().setMaxEntryAge(300s); - ns_log::BufferedLogger::instance().setCountFactor(5s); + ns_log::BufferedLogger::instance().setMaxEntryAge(300); + ns_log::BufferedLogger::instance().setCountFactor(5); } int diff --git a/vespalog/src/test/threads/testthreads.cpp b/vespalog/src/test/threads/testthreads.cpp index 0c9b3a1cdb2..6a9d5c18a18 100644 --- a/vespalog/src/test/threads/testthreads.cpp +++ b/vespalog/src/test/threads/testthreads.cpp @@ -9,6 +9,7 @@ #include <unistd.h> #include <sys/stat.h> #include <cstdlib> +#include <cstring> #include <vector> using std::string; diff --git a/vespalog/src/vespa/log/bufferedlogger.cpp b/vespalog/src/vespa/log/bufferedlogger.cpp index 7ad878a568c..c589e0ae424 100644 --- a/vespalog/src/vespa/log/bufferedlogger.cpp +++ b/vespalog/src/vespa/log/bufferedlogger.cpp @@ -1,9 +1,9 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "bufferedlogger.h" +#include "internal.h" #include <boost/multi_index_container.hpp> #include <boost/multi_index/identity.hpp> -#include <boost/multi_index/member.hpp> #include <boost/multi_index/mem_fun.hpp> #include <boost/multi_index/ordered_index.hpp> #include <boost/multi_index/sequenced_index.hpp> @@ -208,16 +208,25 @@ BufferedLogger::~BufferedLogger() } namespace { - typedef boost::multi_index::nth_index< - BackingBuffer::LogCacheFront, 0>::type LogCacheFrontTimestamp; - typedef boost::multi_index::nth_index< - BackingBuffer::LogCacheFront, 1>::type LogCacheFrontToken; - typedef boost::multi_index::nth_index< - BackingBuffer::LogCacheBack, 0>::type LogCacheBackTimestamp; - typedef boost::multi_index::nth_index< - BackingBuffer::LogCacheBack, 1>::type LogCacheBackToken; - typedef boost::multi_index::nth_index< - BackingBuffer::LogCacheBack, 2>::type LogCacheBackAge; + +typedef boost::multi_index::nth_index< + BackingBuffer::LogCacheFront, 0>::type LogCacheFrontTimestamp; +typedef boost::multi_index::nth_index< + BackingBuffer::LogCacheFront, 1>::type LogCacheFrontToken; +typedef boost::multi_index::nth_index< + BackingBuffer::LogCacheBack, 0>::type LogCacheBackTimestamp; +typedef boost::multi_index::nth_index< + BackingBuffer::LogCacheBack, 1>::type LogCacheBackToken; +typedef boost::multi_index::nth_index< + BackingBuffer::LogCacheBack, 2>::type LogCacheBackAge; + +struct TimeStampWrapper : public Timer { + TimeStampWrapper(system_time timeStamp) : _timeStamp(timeStamp) {} + system_time getTimestamp() const noexcept override { return _timeStamp; } + + system_time _timeStamp; +}; + } void @@ -260,7 +269,7 @@ BackingBuffer::logImpl(Logger& l, Logger::LogLevel level, _cacheBack.get<1>().replace(it2, copy); } else { // If entry didn't already exist, add it to the cache and log it - l.doLogCore(entry._timestamp, level, file, line, message.c_str(), message.size()); + l.doLogCore(TimeStampWrapper(entry._timestamp), level, file, line, message.c_str(), message.size()); _cacheFront.push_back(entry); } trimCache(entry._timestamp); @@ -335,7 +344,7 @@ BackingBuffer::log(const Entry& e) const << " times since " << count_s(e._timestamp.time_since_epoch()) << "." << std::setw(6) << std::setfill('0') << (count_us(e._timestamp.time_since_epoch()) % 1000000) << ")"; - e._logger->doLogCore(_timer->getTimestamp(), e._level, e._file.c_str(), + e._logger->doLogCore(*_timer, e._level, e._file.c_str(), e._line, ost.str().c_str(), ost.str().size()); } } @@ -367,13 +376,13 @@ BufferedLogger::setMaxCacheSize(uint32_t size) { } void -BufferedLogger::setMaxEntryAge(duration maxAge) { - _backing->_maxEntryAge = maxAge; +BufferedLogger::setMaxEntryAge(uint64_t seconds) { + _backing->_maxEntryAge = std::chrono::seconds(seconds); } void -BufferedLogger::setCountFactor(duration factor) { - _backing->_countFactor = factor; +BufferedLogger::setCountFactor(uint64_t seconds) { + _backing->_countFactor = std::chrono::seconds(seconds); } /** Set a fake timer to use for log messages. Used in unit testing. */ diff --git a/vespalog/src/vespa/log/bufferedlogger.h b/vespalog/src/vespa/log/bufferedlogger.h index 31e194e63bb..f3aee2fb3f6 100644 --- a/vespalog/src/vespa/log/bufferedlogger.h +++ b/vespalog/src/vespa/log/bufferedlogger.h @@ -167,10 +167,10 @@ class BackingBuffer; class BufferedLogger { BackingBuffer *_backing; - BufferedLogger(const BufferedLogger & buf); - BufferedLogger & operator = (const BufferedLogger & buf); public: + BufferedLogger(const BufferedLogger & buf) = delete; + BufferedLogger & operator = (const BufferedLogger & buf) = delete; BufferedLogger(); ~BufferedLogger(); @@ -178,8 +178,8 @@ public: // to easier be able to test all aspects of the buffer, and be independent // of the default settings for applications void setMaxCacheSize(uint32_t size); - void setMaxEntryAge(duration seconds); - void setCountFactor(duration factor); + void setMaxEntryAge(uint64_t seconds); + void setCountFactor(uint64_t seconds); void doLog(Logger&, Logger::LogLevel level, const char *file, int line, const std::string& token, @@ -188,9 +188,6 @@ public: /** Empty buffer and write all log entries in it. */ void flush(); - /** Gives all current content of log buffer. Useful for debugging. */ - std::string toString() const; - /** Set a fake timer to use for log messages. Used in unit testing. */ void setTimer(std::unique_ptr<Timer> timer); diff --git a/vespalog/src/vespa/log/component.cpp b/vespalog/src/vespa/log/component.cpp index 009a69ad0c5..36b1d15e457 100644 --- a/vespalog/src/vespa/log/component.cpp +++ b/vespalog/src/vespa/log/component.cpp @@ -9,6 +9,7 @@ LOG_SETUP_INDIRECT(".log.control", "$Id$"); #include "component.h" #include "control-file.h" #include "internal.h" +#include <cstring> namespace ns_log { diff --git a/vespalog/src/vespa/log/internal.h b/vespalog/src/vespa/log/internal.h index c25c7cc44b6..7e6bf16f39f 100644 --- a/vespalog/src/vespa/log/internal.h +++ b/vespalog/src/vespa/log/internal.h @@ -3,6 +3,7 @@ #include <string> #include <cstdlib> +#include <chrono> namespace ns_log { @@ -20,4 +21,24 @@ public: [[nodiscard]] const char *what() const { return _what.c_str(); } }; +using system_time = std::chrono::system_clock::time_point; +using duration = std::chrono::nanoseconds; + +constexpr int64_t +count_s(duration d) noexcept { + return std::chrono::duration_cast<std::chrono::seconds>(d).count(); +} + +constexpr int64_t +count_us(duration d) noexcept { + return std::chrono::duration_cast<std::chrono::microseconds>(d).count(); +} + +// XXX this is way too complicated, must be some simpler way to do this +/** Timer class used to retrieve timestamp, such that we can override in test */ +struct Timer { + virtual ~Timer() = default; + virtual system_time getTimestamp() const noexcept; +}; + } // end namespace ns_log diff --git a/vespalog/src/vespa/log/llparser.cpp b/vespalog/src/vespa/log/llparser.cpp index 1585b9fde33..063220e50ef 100644 --- a/vespalog/src/vespa/log/llparser.cpp +++ b/vespalog/src/vespa/log/llparser.cpp @@ -4,6 +4,7 @@ #include "llparser.h" #include "internal.h" #include <cstdlib> +#include <cstring> #include <unistd.h> #include <sys/time.h> #include <cassert> diff --git a/vespalog/src/vespa/log/log-target-file.cpp b/vespalog/src/vespa/log/log-target-file.cpp index 4337d6b5bbb..87a9810e3c7 100644 --- a/vespalog/src/vespa/log/log-target-file.cpp +++ b/vespalog/src/vespa/log/log-target-file.cpp @@ -1,15 +1,15 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#include "log.h" +LOG_SETUP(".log"); +#include "log-target-file.h" +#include "internal.h" + #include <unistd.h> #include <cstring> #include <fcntl.h> #include <cerrno> #include <cassert> -#include "log.h" -LOG_SETUP(".log"); -#include "log-target-file.h" -#include "internal.h" - namespace ns_log { #ifndef O_LARGEFILE diff --git a/vespalog/src/vespa/log/log.cpp b/vespalog/src/vespa/log/log.cpp index 9ca993b84fc..73cbeef08aa 100644 --- a/vespalog/src/vespa/log/log.cpp +++ b/vespalog/src/vespa/log/log.cpp @@ -6,7 +6,6 @@ LOG_SETUP_INDIRECT(".log", "$Id$"); #undef LOG #define LOG LOG_INDIRECT -#include "lock.h" #include "log-target.h" #include "internal.h" #include "control-file.h" @@ -15,13 +14,15 @@ LOG_SETUP_INDIRECT(".log", "$Id$"); #include <vespa/defaults.h> #include <cassert> #include <cstdarg> +#include <cstring> +#include <cinttypes> #include <unistd.h> #include <sys/time.h> namespace ns_log { system_time -Timer::getTimestamp() const { +Timer::getTimestamp() const noexcept { return std::chrono::system_clock::now(); } @@ -131,7 +132,7 @@ Logger::ensureHostname() Logger::Logger(const char *name, const char *rcsId) : _logLevels(ControlFile::defaultLevels()), - _timer(new Timer()) + _timer(std::make_unique<Timer>()) { _numInstances++; memset(_rcsId, 0, sizeof(_rcsId)); @@ -168,7 +169,6 @@ Logger::Logger(const char *name, const char *rcsId) } } - Logger::~Logger() { _numInstances--; @@ -186,6 +186,10 @@ Logger::~Logger() } } +void +Logger::setTimer(std::unique_ptr<Timer> timer) { + _timer = std::move(timer); +} int Logger::setRcsId(const char *id) @@ -216,7 +220,7 @@ Logger::tryLog(int sizeofPayload, LogLevel level, const char *file, int line, co const int actualSize = vsnprintf(payload, sizeofPayload, fmt, args); if (actualSize < sizeofPayload) { - doLogCore(_timer->getTimestamp(), level, file, line, payload, actualSize); + doLogCore(*_timer, level, file, line, payload, actualSize); } delete[] payload; return actualSize; @@ -238,9 +242,10 @@ Logger::doLog(LogLevel level, const char *file, int line, const char *fmt, ...) } void -Logger::doLogCore(system_time timestamp, LogLevel level, +Logger::doLogCore(const Timer & timer, LogLevel level, const char *file, int line, const char *msg, size_t msgSize) { + system_time timestamp = timer.getTimestamp(); const size_t sizeofEscapedPayload(msgSize*4+1); const size_t sizeofTotalMessage(sizeofEscapedPayload + 1000); auto escapedPayload = std::make_unique<char[]>(sizeofEscapedPayload); @@ -349,35 +354,20 @@ Logger::doEventStarted(const char *name) void Logger::doEventStopped(const char *name, pid_t pid, int exitCode) { - doLog(event, "", 0, "stopped/1 name=\"%s\" pid=%d exitcode=%d", name, - static_cast<int>(pid), exitCode); -} - -void -Logger::doEventReloading(const char *name) -{ - doLog(event, "", 0, "reloading/1 name=\"%s\"", name); -} - -void -Logger::doEventReloaded(const char *name) -{ - doLog(event, "", 0, "reloaded/1 name=\"%s\"", name); + doLog(event, "", 0, "stopped/1 name=\"%s\" pid=%d exitcode=%d", name, static_cast<int>(pid), exitCode); } void Logger::doEventCrash(const char *name, pid_t pid, int signal) { - doLog(event, "", 0, "crash/1 name=\"%s\" pid=%d signal=\"%s\"", name, pid, - strsignal(signal)); + doLog(event, "", 0, "crash/1 name=\"%s\" pid=%d signal=\"%s\"", name, pid, strsignal(signal)); } void Logger::doEventProgress(const char *name, double value, double total) { if (total > 0) { - doLog(event, "", 0, "progress/1 name=\"%s\" value=%.18g total=%.18g", - name, value, total); + doLog(event, "", 0, "progress/1 name=\"%s\" value=%.18g total=%.18g", name, value, total); } else { doLog(event, "", 0, "progress/1 name=\"%s\" value=%.18g", name, value); } diff --git a/vespalog/src/vespa/log/log.h b/vespalog/src/vespa/log/log.h index 88d24ba7e18..857bf4f2b97 100644 --- a/vespalog/src/vespa/log/log.h +++ b/vespalog/src/vespa/log/log.h @@ -2,17 +2,9 @@ #pragma once #include <memory> -#include <cstdint> #include <new> // for placement new -#include <cstdlib> // for malloc -#include <cstring> // for memset -#include <cstdarg> // for va_list -#include <cinttypes> -#include <chrono> #include <sys/types.h> // for pid_t - - /** * If this macro is defined, the regular LOG calls will go through the * buffered logger, using the whole messages as tokens. @@ -27,7 +19,7 @@ static ns_log::Logger ns_log_logger(__VA_ARGS__) // NOLINT #define LOG_SETUP_INDIRECT(x, id) \ -static ns_log::Logger *ns_log_indirect_logger=NULL; \ +static ns_log::Logger *ns_log_indirect_logger=nullptr; \ static bool logInitialised = false; \ static const char *logName = x; \ static const char *indirectRcsId = id @@ -37,9 +29,6 @@ static const char *indirectRcsId = id #define LOG_INDIRECT_WOULD_LOG(levelName) \ ns_log_indirect_logger->wants(ns_log::Logger::levelName) -#define LOG_RCSID(x) \ -static int log_dummmy __attribute__((unused)) = ns_log_logger.setRcsId(x) - // Define LOG if not using log buffer. Otherwise log buffer will define them #ifndef VESPA_LOG_USELOGBUFFERFORREGULARLOG #define LOG(level, ...) \ @@ -147,25 +136,7 @@ namespace ns_log { class LogTarget; class ControlFile; -using system_time = std::chrono::system_clock::time_point; -using duration = std::chrono::nanoseconds; - -constexpr int64_t -count_s(duration d) { - return std::chrono::duration_cast<std::chrono::seconds>(d).count(); -} - -constexpr int64_t -count_us(duration d) { - return std::chrono::duration_cast<std::chrono::microseconds>(d).count(); -} - -// XXX this is way too complicated, must be some simpler way to do this -/** Timer class used to retrieve timestamp, such that we can override in test */ -struct Timer { - virtual ~Timer() = default; - virtual system_time getTimestamp() const; -}; +struct Timer; class Logger { public: @@ -182,9 +153,6 @@ public: static bool fakePid; private: - Logger(const Logger &); - Logger& operator =(const Logger &); - unsigned int *_logLevels; static char _prefix[64]; @@ -214,6 +182,8 @@ private: public: ~Logger(); explicit Logger(const char *name, const char *rcsId = nullptr); + Logger(const Logger &) = delete; + Logger & operator=(const Logger &) = delete; int setRcsId(const char *rcsId); static const char *levelName(LogLevel level); @@ -227,14 +197,12 @@ public: * * @param timestamp Time in microseconds. */ - void doLogCore(system_time timestamp, LogLevel level, + void doLogCore(const Timer &, LogLevel level, const char *file, int line, const char *msg, size_t msgSize); void doEventStarting(const char *name); void doEventStopping(const char *name, const char *why); void doEventStarted(const char *name); void doEventStopped(const char *name, pid_t pid, int exitCode); - void doEventReloading(const char *name); - void doEventReloaded(const char *name); void doEventCrash(const char *name, pid_t pid, int signal); void doEventProgress(const char *name, double value, double total = 0); void doEventCount(const char *name, uint64_t value); @@ -242,7 +210,7 @@ public: void doEventState(const char *name, const char *value); // Only for unit testing - void setTimer(std::unique_ptr<Timer> timer) { _timer = std::move(timer); } + void setTimer(std::unique_ptr<Timer> timer); // Only for internal use static LogTarget *getCurrentTarget(); |