Switch default behavior to not capturing logs

Switch default behavior to not capturing logs

Having log collection enabled by default can result in forwarding unnecessary noise to logstash, for example with testing containers.

This commit reverses the default behavior to not capturing logs for a container unless it has the new org.discourse.mobystash.enable label set to a true value. Support for the org.discourse.mobystash.disable label is removed.

If the enable label is not used, any additional labels are ignored.

diff --git a/Dockerfile b/Dockerfile
index 6a88ab6..2c202e0 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -32,7 +32,7 @@ COPY lib /home/mobystash/lib
 COPY bin/* /usr/local/bin/
 
 EXPOSE 9367
-LABEL org.discourse.service._prom-exp.port=9367 org.discourse.service._prom-exp.instance=mobystash org.discourse.mobystash.disable=yes
+LABEL org.discourse.service._prom-exp.port=9367 org.discourse.service._prom-exp.instance=mobystash
 
 USER mobystash
 WORKDIR /home/mobystash
diff --git a/README.md b/README.md
index 3137d4a..7f5a386 100644
--- a/README.md
+++ b/README.md
@@ -269,24 +269,22 @@ sensible default which works OK in at least some circumstances.
 
 # Per-container Configuration
 
-By default, `mobystash` will forward all logs from a container to logstash.
-If you wish to opt-out of that logging, filter which logs are forwarded, or
+By default, `mobystash` will not forward any logs from a container to logstash.
+If you wish to opt-in to that logging, filter which logs are forwarded, or
 provide additional fields to the logged events, you can [label your
 containers](https://docs.docker.com/engine/userguide/labels-custom-metadata/)
 as follows.
 
 
-## Opt out of logging
+## Opt in to logging
 
-Some containers provide their own ship-to-logstash functionality, and
-provide a "convenience copy" of their log data to Docker.  To prevent
-`mobystash` from sending duplicates of those log entries, containers can
-label themselves to tell `mobystash` to not bother logging their output at
-all, by setting the `org.discourse.mobystash.disable` label to a true-ish
-value (one of `yes`, `1`, `true`, or `on` -- all case-insensitive), like
-this:
+In order for mobystash to forward logs from a container, the
+`org.discourse.mobystash.enable` should be set to a true-ish value (one of
+`yes`, `1`, `true`, or `on` -- all case-insensitive), like this:
 
-    --label org.discourse.mobystash.disable=yes
+    --label org.discourse.mobystash.enable=yes
+
+Note that if this label is not used, any additional labels are ignored.
 
 
 ## Filtering forwarded log entries
diff --git a/lib/mobystash/container.rb b/lib/mobystash/container.rb
index ee2c926..bc20618 100644
--- a/lib/mobystash/container.rb
+++ b/lib/mobystash/container.rb
@@ -58,7 +58,7 @@ module Mobystash
 
       @name = (docker_data.info["Name"] || docker_data.info["Names"].first).sub(/\A\//, '')
 
-      @capture_logs = true
+      @capture_logs = false
       @parse_syslog = false
 
       @tags = {
@@ -177,9 +177,9 @@ module Mobystash
 
       labels.each do |lbl, val|
         case lbl
-        when "org.discourse.mobystash.disable"
-          @logger.debug(progname) { "Found disable label, value: #{val.inspect}" }
-          @capture_logs = !(val =~ /\Ayes|y|1|on|true|t\z/i)
+        when "org.discourse.mobystash.enable"
+          @logger.debug(progname) { "Found enable label, value: #{val.inspect}" }
+          @capture_logs = (val =~ /\Ayes|y|1|on|true|t\z/i)
           @logger.debug(progname) { "@capture_logs is now #{@capture_logs.inspect}" }
         when "org.discourse.mobystash.filter_regex"
           @logger.debug(progname) { "Found filter_regex label, value: #{val.inspect}" }

GitHub sha: eea70802bf4a742c4390af5a4385d4c99cadc09f

This commit appears in #14 which was approved by saj. It was merged by chipflake.