def open_port(path):
 
-  global proc
+  global proc, debug
 
-  print "Opening path "+path
+  if debug>0:
+    print "Opening path "+path
 
   if path == "-":
     return sys.stdin
     try:
       line=read_port(ser)
       if line=="<<TIMEOUT>>":
-        print "Reopening port..."
-        print line
+        if debug>0:
+          print "Reopening port..."
+          print line
         ser.close()
         if proc:
           try:
-            print "Terminating process..."
+            if debug>0:
+              print "Terminating process..."
             proc.terminate()
             sleep(5)
           finally:
 
 def print_log(str):
   global logging
-  print str
+  if debug>0:
+    print str
   if logging == "on":
     system("logger -t weathermon \""+str+"\"")
 
 
   queue=c.fetchall()
 
-  pprint(queue)
+  if debug>1:
+    pprint(queue)
 
   for (sensor,value) in queue:
     param[sensor] = value  
-  pprint (param)
+  
+  if debug>1:
+    pprint (param)
 
   url = "http://narodmon.ru/post.php"
 
 
   queue=c.fetchall()
 
-  pprint(queue)
+  if debug>1:
+    pprint(queue)
 
   for (sensor,value) in queue:
     params[sensor]=value
-  pprint (params)
+  if debug>1:  
+    pprint (params)
 
   try:
 
 
 def init():
 
-  global dbhost,dbuser,dbpasswd,path,serialnum,logging;
+  global dbhost,dbuser,dbpasswd,path,serialnum,logging,debug;
   global timeout,baud,narmon,devid;
   global owmuser,owmpasswd,owm_temp,owm_pres,owm_humi,owm_lat,owm_lon,owm_station;
   global alarm_script;
     dbhost = cfg.get("mysql","host")
     dbuser = cfg.get("mysql","user")
     dbpasswd = cfg.get("mysql","passwd")
+    try:
+      debug = cfg.get("logging","debug")
+    except:
+      debug = 0  
     try:
       path = cfg.get("serial","port");
     except: