aboutsummaryrefslogtreecommitdiff
path: root/src/tracer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tracer.c')
-rw-r--r--src/tracer.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/tracer.c b/src/tracer.c
index be2f3cc..3b39759 100644
--- a/src/tracer.c
+++ b/src/tracer.c
@@ -24,6 +24,7 @@
#include <stdint.h>
#include <stdlib.h>
+#include <string.h>
#include <otf.h>
@@ -59,6 +60,23 @@ int ppaml_tracer_init(
done: return r;
}
+int ppaml_tracer_init_from_env(ppaml_tracer_t *const tracer)
+{
+ int r = 0;
+ // Figure out where to put the trace.
+ const char *const report_name_base = getenv("PPAMLTRACER_TRACE_BASE");
+ require_nonnull(report_name_base, 5);
+ if (report_name_base[0] == '\0') {
+ /* The variable exists, but it's empty, so we can't do anything
+ * with it. */
+ r = 5;
+ goto done;
+ }
+ // Create the trace.
+ r = ppaml_tracer_init(tracer, report_name_base);
+done: return r;
+}
+
int ppaml_tracer_done(ppaml_tracer_t *const tracer)
{
int r = 0;