about summary refs log tree commit diff
path: root/src/libutil/logging.hh
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2018-03-15T13·56+0100
committerGitHub <noreply@github.com>2018-03-15T13·56+0100
commit7b8914825a6b02173976eae0ca59053085d4b20a (patch)
treea913c0a57ea199dad59e4bb45a6f16f05941e797 /src/libutil/logging.hh
parentcfdbfa6b2cc27ae5b98c5f27599bbc0fc6a104c1 (diff)
parentbe54f4a0b6f160f8a2b0b9e9c988fb5251f70a97 (diff)
Merge pull request #1965 from masaeedu/master
Wrap thread local in function for Cygwin
Diffstat (limited to 'src/libutil/logging.hh')
-rw-r--r--src/libutil/logging.hh11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/libutil/logging.hh b/src/libutil/logging.hh
index ca768d555add..678703102e9b 100644
--- a/src/libutil/logging.hh
+++ b/src/libutil/logging.hh
@@ -77,7 +77,8 @@ public:
     virtual void result(ActivityId act, ResultType type, const Fields & fields) { };
 };
 
-extern thread_local ActivityId curActivity;
+ActivityId getCurActivity();
+void setCurActivity(const ActivityId activityId);
 
 struct Activity
 {
@@ -86,10 +87,10 @@ struct Activity
     const ActivityId id;
 
     Activity(Logger & logger, Verbosity lvl, ActivityType type, const std::string & s = "",
-        const Logger::Fields & fields = {}, ActivityId parent = curActivity);
+        const Logger::Fields & fields = {}, ActivityId parent = getCurActivity());
 
     Activity(Logger & logger, ActivityType type,
-        const Logger::Fields & fields = {}, ActivityId parent = curActivity)
+        const Logger::Fields & fields = {}, ActivityId parent = getCurActivity())
         : Activity(logger, lvlError, type, "", fields, parent) { };
 
     Activity(const Activity & act) = delete;
@@ -121,8 +122,8 @@ struct Activity
 struct PushActivity
 {
     const ActivityId prevAct;
-    PushActivity(ActivityId act) : prevAct(curActivity) { curActivity = act; }
-    ~PushActivity() { curActivity = prevAct; }
+    PushActivity(ActivityId act) : prevAct(getCurActivity()) { setCurActivity(act); }
+    ~PushActivity() { setCurActivity(prevAct); }
 };
 
 extern Logger * logger;