about summary refs log tree commit diff
path: root/src/libutil/logging.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil/logging.cc')
-rw-r--r--src/libutil/logging.cc22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/libutil/logging.cc b/src/libutil/logging.cc
index d9e8d22d7685..2d0acca24216 100644
--- a/src/libutil/logging.cc
+++ b/src/libutil/logging.cc
@@ -1,9 +1,16 @@
 #include "logging.hh"
 #include "util.hh"
 
+#include <atomic>
+
 namespace nix {
 
-Logger * logger = 0;
+Logger * logger = makeDefaultLogger();
+
+void Logger::warn(const std::string & msg)
+{
+    log(lvlInfo, ANSI_RED "warning:" ANSI_NORMAL " " + msg);
+}
 
 class SimpleLogger : public Logger
 {
@@ -37,12 +44,7 @@ public:
         writeToStderr(prefix + (tty ? fs.s : filterANSIEscapes(fs.s)) + "\n");
     }
 
-    void startActivity(Activity & activity, Verbosity lvl, const FormatOrString & fs) override
-    {
-        log(lvl, fs);
-    }
-
-    void stopActivity(Activity & activity) override
+    void event(const Event & ev) override
     {
     }
 };
@@ -52,7 +54,7 @@ Verbosity verbosity = lvlInfo;
 void warnOnce(bool & haveWarned, const FormatOrString & fs)
 {
     if (!haveWarned) {
-        printError(format("warning: %1%") % fs.s);
+        warn(fs.s);
         haveWarned = true;
     }
 }
@@ -74,4 +76,8 @@ Logger * makeDefaultLogger()
     return new SimpleLogger();
 }
 
+std::atomic<uint64_t> Activity::nextId{(uint64_t) getpid() << 32};
+
+Activity::Activity() : id(nextId++) { };
+
 }