aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-11-18 18:15:45 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-11-18 18:22:16 +0000
commita330fa13973762f0b05e73c0ef3969fce28734fd (patch)
tree388443c8631a10816981c4181b260d9b8e0f87e1 /vespalib
parent78bfefbf3fd11a655560c7237bf4106aca2458b2 (diff)
Reduce exposure of TraceNode even further.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/trace/trace.cpp5
-rw-r--r--vespalib/src/vespa/vespalib/trace/trace.h39
2 files changed, 16 insertions, 28 deletions
diff --git a/vespalib/src/vespa/vespalib/trace/trace.cpp b/vespalib/src/vespa/vespalib/trace/trace.cpp
index ea93f574ed0..df9b5111d70 100644
--- a/vespalib/src/vespa/vespalib/trace/trace.cpp
+++ b/vespalib/src/vespa/vespalib/trace/trace.cpp
@@ -36,6 +36,11 @@ Trace::toString() const {
return _root ? _root->toString(31337) : "";
}
+string
+Trace::encode() const {
+ return isEmpty() ? "" : getRoot().encode();
+}
+
void
Trace::clear() {
_level = 0;
diff --git a/vespalib/src/vespa/vespalib/trace/trace.h b/vespalib/src/vespa/vespalib/trace/trace.h
index 1300f121404..4b3752638f1 100644
--- a/vespalib/src/vespa/vespalib/trace/trace.h
+++ b/vespalib/src/vespa/vespalib/trace/trace.h
@@ -50,22 +50,10 @@ public:
return *this;
}
- /**
- * Set the trace level. 0 means no tracing, 9 means enable all tracing.
- *
- * @param level The level to set.
- * @return This, to allow chaining.
- */
- Trace &setLevel(uint32_t level) {
+ void setLevel(uint32_t level) {
_level = std::min(level, 9u);
- return *this;
}
- /**
- * Returns the trace level.
- *
- * @return The trace level.
- */
uint32_t getLevel() const { return _level; }
/**
@@ -98,36 +86,31 @@ public:
}
}
- /**
- * Adds a child node to this.
- *
- * @param child The child to add.
- * @return This, to allow chaining.
- */
- void addChild(TraceNode && child) {
- ensureRoot().addChild(std::move(child));
- }
-
void setStrict(bool strict) {
ensureRoot().setStrict(strict);
}
+ void addChild(TraceNode && child) {
+ ensureRoot().addChild(std::move(child));
+ }
void addChild(Trace && child) {
if (!child.isEmpty()) {
addChild(std::move(*child._root));
}
}
+ //TODO This one should go away as we should prefer moving
+ void addChild(const Trace & child) {
+ if (!child.isEmpty()) {
+ addChild(TraceNode(*child._root));
+ }
+ }
- /**
- * Returns a const reference to the root of the trace tree.
- *
- * @return The root.
- */
const TraceNode &getRoot() const { return *_root; }
bool isEmpty() const { return !_root || _root->isEmpty(); }
uint32_t getNumChildren() const { return _root ? _root->getNumChildren() : 0; }
const TraceNode & getChild(uint32_t child) const { return getRoot().getChild(child); }
+ string encode() const;
/**
* Returns a string representation of the contained trace tree. This is a