Merge pull request #36 from xujyan/jyx/log_offer

Improve logging
diff --git a/mysos/scheduler/mysos_scheduler.py b/mysos/scheduler/mysos_scheduler.py
index df86660..16ec00a 100644
--- a/mysos/scheduler/mysos_scheduler.py
+++ b/mysos/scheduler/mysos_scheduler.py
@@ -140,16 +140,14 @@
       dest='installer_args',
       default=None,
       help='Arguments for MySQL installer directly passed along to and parsed by the installer. '
-           'e.g., a serialized JSON string'
-  )
+           'e.g., a serialized JSON string')
 
   app.add_option(
       '--backup_store_args',
       dest='backup_store_args',
       default=None,
       help="Arguments for the store for MySQL backups. Its use and format are defined by the "
-           "backup store implementation. e.g., It can be a serialized JSON string"
-  )
+           "backup store implementation. e.g., It can be a serialized JSON string")
 
   app.add_option(
       '--framework_authentication_file',
@@ -157,8 +155,7 @@
       default=None,
       help="Path to the key file for authenticating the framework against Mesos master. Framework "
            "will fail to register with Mesos if authentication is required by Mesos and this "
-           "option is not provided"
-  )
+           "option is not provided")
 
   app.add_option(
       '--executor_source_prefix',
@@ -168,8 +165,13 @@
            "to support metrics tracking by external utilities. The format of ExecutorInfo.source "
            "is '<prefix>.<cluster_name>.<server_id>'. This flag specifies the prefix to use in the "
            "'source' field. e.g., it can be '<availability_zone>.<mesos_cluster>'. There is no "
-           "preceding period if <prefix> is empty"
-  )
+           "preceding period if <prefix> is empty")
+
+  app.add_option(
+      '--verbose',
+      dest='verbose',
+      default=None,
+      help="Turn on verbose logging")
 
   def main(args, options):
     log.info("Options in use: %s", options)
@@ -198,6 +200,9 @@
     if not options.scheduler_keypath:
       app.error('Must specify --scheduler_keypath')
 
+    if options.verbose:
+      LogOptions.set_stderr_log_level('google:DEBUG')
+
     try:
       election_timeout = parse_time(options.election_timeout)
       framework_failover_timeout = parse_time(options.framework_failover_timeout)
diff --git a/mysos/scheduler/scheduler.py b/mysos/scheduler/scheduler.py
index 07e8892..52986ae 100644
--- a/mysos/scheduler/scheduler.py
+++ b/mysos/scheduler/scheduler.py
@@ -401,10 +401,12 @@
           log.info("Declining offer %s for %s because '%s'" % (
               offer.id.value, INCOMPATIBLE_ROLE_OFFER_REFUSE_DURATION, e))
         else:
-          log.info("Declining offer %s because no launcher can use this offer" % offer.id.value)
+          log.info("Declining offer %s because no launcher accepted this offer" % offer.id.value)
           # Mesos scheduler Python binding doesn't deal with filters='None' properly.
           # See https://issues.apache.org/jira/browse/MESOS-2567.
           filters = mesos_pb2.Filters()
+
+        log.debug(offer)
         self._driver.declineOffer(offer.id, filters)
 
   @logged