chiark / gitweb /
core/snapshot: log info when snapshots are created and removed
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 22 Jun 2014 18:20:08 +0000 (14:20 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 22 Jun 2014 19:30:28 +0000 (15:30 -0400)
Snapshot mechanism is not used very much, but snapshot creation/destruction
should be at least as verbose as normal unit starting/stopping.

TODO
src/core/snapshot.c

diff --git a/TODO b/TODO
index 09d8bd38a44de3ef29af0b103cc2d2ba78fcefbb..a928c8126ba8fa5e939985367add89c734d94945 100644 (file)
--- a/TODO
+++ b/TODO
@@ -214,8 +214,6 @@ Features:
   - add 'set -e' to scripts in test/
   - make stuff in test/ work with separate output dir
 
-* systemctl delete x.snapshot leaves no trace in logs (at least at default level).
-
 * seems that when we follow symlinks to units we prefer the symlink
   destination path over /etc and /usr. We should not do that. Instead
   /etc should always override /run+/usr and also any symlink
index d914af20e7c0651f1301fa8be1d7874c249c1119..5eed615a150deee677304f7bc9afa15f1ab941ef 100644 (file)
@@ -51,10 +51,11 @@ static void snapshot_set_state(Snapshot *s, SnapshotState state) {
         s->state = state;
 
         if (state != old_state)
-                log_debug("%s changed %s -> %s",
-                          UNIT(s)->id,
-                          snapshot_state_to_string(old_state),
-                          snapshot_state_to_string(state));
+                log_debug_unit(UNIT(s)->id,
+                               "%s changed %s -> %s",
+                               UNIT(s)->id,
+                               snapshot_state_to_string(old_state),
+                               snapshot_state_to_string(state));
 
         unit_notify(UNIT(s), state_translation_table[old_state], state_translation_table[state], true);
 }
@@ -154,7 +155,7 @@ static int snapshot_deserialize_item(Unit *u, const char *key, const char *value
 
                 state = snapshot_state_from_string(value);
                 if (state < 0)
-                        log_debug("Failed to parse state value %s", value);
+                        log_debug_unit(u->id, "Failed to parse state value %s", value);
                 else
                         s->deserialized_state = state;
 
@@ -162,7 +163,7 @@ static int snapshot_deserialize_item(Unit *u, const char *key, const char *value
 
                 r = parse_boolean(value);
                 if (r < 0)
-                        log_debug("Failed to parse cleanup value %s", value);
+                        log_debug_unit(u->id, "Failed to parse cleanup value %s", value);
                 else
                         s->cleanup = r;
 
@@ -172,7 +173,7 @@ static int snapshot_deserialize_item(Unit *u, const char *key, const char *value
                 if (r < 0)
                         return r;
         } else
-                log_debug("Unknown serialization key '%s'", key);
+                log_debug_unit(u->id, "Unknown serialization key '%s'", key);
 
         return 0;
 }
@@ -257,6 +258,8 @@ int snapshot_create(Manager *m, const char *name, bool cleanup, sd_bus_error *e,
         SNAPSHOT(u)->cleanup = cleanup;
         *_s = SNAPSHOT(u);
 
+        log_info_unit(u->id, "Created snapshot %s.", u->id);
+
         return 0;
 
 fail:
@@ -269,6 +272,8 @@ fail:
 void snapshot_remove(Snapshot *s) {
         assert(s);
 
+        log_info_unit(UNIT(s)->id, "Removing snapshot %s.", UNIT(s)->id);
+
         unit_add_to_cleanup_queue(UNIT(s));
 }