Notice: curl_setopt(): CURLOPT_SSL_VERIFYHOST no longer accepts the value 1, value...
[plcapi.git] / PLC / Logger.py
index a48ac7d..6102972 100644 (file)
@@ -1,11 +1,23 @@
 # pylint: disable=c0103
 
+import os
 import logging
 import logging.config
 
 # we essentially need one all-purpose logger
 # that goes into /var/log/plcapi.log
 
+# for debugging
+global_filename = "/var/log/plcapi.log"
+if 'PLCAPILOG' in os.environ:
+    global_filename = os.environ['PLCAPILOG']
+else:
+    try:
+        with open(global_filename, 'a') as just_checking:
+            pass
+    except OSError:
+        global_filename = "/tmp/plcapi.log"
+
 plcapi_logging_config = {
     'version': 1,
     # IMPORTANT: we may be imported by something else, like sfa, so:
@@ -19,7 +31,7 @@ plcapi_logging_config = {
     },
     'handlers': {
         'plcapi': {
-            'filename': '/var/log/plcapi.log',
+            'filename': global_filename,
             'level': 'INFO',
             'class': 'logging.FileHandler',
             'formatter': 'standard',