aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bbot/agent.cxx6
-rw-r--r--bbot/diagnostics.cxx10
-rw-r--r--bbot/diagnostics.hxx22
-rw-r--r--bbot/machine.cxx8
4 files changed, 29 insertions, 17 deletions
diff --git a/bbot/agent.cxx b/bbot/agent.cxx
index 09156f2..80ff475 100644
--- a/bbot/agent.cxx
+++ b/bbot/agent.cxx
@@ -85,7 +85,7 @@ bootstrap_machine (const dir_path& md,
const machine_manifest& mm,
optional<bootstrapped_machine_manifest> obmm)
{
- tracer trace ("bootstrap_machine");
+ tracer trace ("bootstrap_machine", md.string ().c_str ());
bootstrapped_machine_manifest r {
mm,
@@ -252,7 +252,7 @@ static pair<bootstrapped_machine_manifests, dir_paths>
enumerate_machines (const dir_path& machines)
try
{
- tracer trace ("enumerate_machines");
+ tracer trace ("enumerate_machines", machines.string ().c_str ());
bootstrapped_machine_manifests rm;
dir_paths rd;
@@ -544,7 +544,7 @@ perform_task (const dir_path& md,
const task_manifest& tm)
try
{
- tracer trace ("perform_task");
+ tracer trace ("perform_task", md.string ().c_str ());
result_manifest r {
tm.name,
diff --git a/bbot/diagnostics.cxx b/bbot/diagnostics.cxx
index f3a2bb9..d528221 100644
--- a/bbot/diagnostics.cxx
+++ b/bbot/diagnostics.cxx
@@ -25,14 +25,20 @@ namespace bbot
r << type_;
if (name_ != nullptr)
- r << name_ << ": ";
+ r << name_;
+
+ if (data_ != nullptr)
+ r << '(' << data_ << ')';
+
+ if (name_ != nullptr || data_ != nullptr)
+ r << ": ";
}
const char* trace_type = "trace: ";
const char* trace_indent = "\n ";
trace_mark_base::
- trace_mark_base (const char* name, const void* data)
+ trace_mark_base (const char* name, const char* data)
: basic_mark_base (trace_type, trace_indent, name, data)
{
}
diff --git a/bbot/diagnostics.hxx b/bbot/diagnostics.hxx
index 36a3cf2..696a912 100644
--- a/bbot/diagnostics.hxx
+++ b/bbot/diagnostics.hxx
@@ -49,8 +49,8 @@ namespace bbot
struct simple_prologue_base
{
explicit
- simple_prologue_base (const char* type, const char* name)
- : type_ (type), name_ (name) {}
+ simple_prologue_base (const char* type, const char* name, const char* data)
+ : type_ (type), name_ (name), data_ (data) {}
void
operator() (const diag_record& r) const;
@@ -58,17 +58,23 @@ namespace bbot
private:
const char* type_;
const char* name_;
+ const char* data_;
};
struct basic_mark_base
{
using simple_prologue = butl::diag_prologue<simple_prologue_base>;
+ // If data if not NULL, then we print it as (data) after name. For
+ // example:
+ //
+ // trace: main(foo): bar
+ //
explicit
basic_mark_base (const char* type,
const char* indent = "\n ",
const char* name = nullptr,
- const void* data = nullptr,
+ const char* data = nullptr,
diag_epilogue* epilogue = nullptr)
: type_ (type), name_ (name), data_ (data),
indent_ (indent), epilogue_ (epilogue) {}
@@ -76,13 +82,13 @@ namespace bbot
simple_prologue
operator() () const
{
- return simple_prologue (indent_, epilogue_, type_, name_);
+ return simple_prologue (indent_, epilogue_, type_, name_, data_);
}
public:
const char* type_;
const char* name_;
- const void* data_;
+ const char* data_;
const char* indent_;
diag_epilogue* const epilogue_;
@@ -102,7 +108,7 @@ namespace bbot
struct trace_mark_base: basic_mark_base
{
explicit
- trace_mark_base (const char* name, const void* data = nullptr);
+ trace_mark_base (const char* name, const char* data = nullptr);
};
using trace_mark = butl::diag_mark<trace_mark_base>;
@@ -119,7 +125,7 @@ namespace bbot
explicit
fail_mark_base (const char* type,
const char* indent = "\n ",
- const void* data = nullptr)
+ const char* data = nullptr)
: basic_mark_base (type,
indent,
nullptr,
@@ -136,7 +142,7 @@ namespace bbot
operator() (bool hard = true) const
{
if (hard)
- return simple_prologue (indent_, epilogue_, type_, name_);
+ return simple_prologue (indent_, epilogue_, type_, name_, data_);
simple_prologue r (error ());
r.epilogue = epilogue_;
diff --git a/bbot/machine.cxx b/bbot/machine.cxx
index 8bc6359..0c8a0e5 100644
--- a/bbot/machine.cxx
+++ b/bbot/machine.cxx
@@ -80,10 +80,10 @@ namespace bbot
static string
create_tap (const string& br, uint16_t port)
{
- tracer trace ("create_tap");
-
string t ("tap" + to_string (tc_num));
+ tracer trace ("create_tap", t.c_str ());
+
// First try to delete it in case there is one from a previous run.
//
iptables (trace, "-D", t, br, port, true); // Ignore errors.
@@ -101,7 +101,7 @@ namespace bbot
static void
destroy_tap (const string& t, const string& br, uint16_t port)
{
- tracer trace ("destroy_tap");
+ tracer trace ("destroy_tap", t.c_str ());
iptables (trace, "-D", t, br, port); // Delete.
run (trace, "sudo", "ip", "tuntap", "delete", t, "mode", "tap");
}
@@ -204,7 +204,7 @@ namespace bbot
vnc ("127.0.0.1:" + to_string (5900 + tc_num)),
monitor ("/tmp/" + tc_name + "-monitor")
{
- tracer trace ("kvm_machine");
+ tracer trace ("kvm_machine", md.string ().c_str ());
if (sizeof (sockaddr_un::sun_path) <= monitor.size ())
throw invalid_argument ("monitor unix socket path too long");