Comments (5)
This looks good. The queue is a nice solution to the chicken and egg problem. I've tested with no log file, log file configured, and a log file that can't be created: no such directory and permission denied. All looks good.
In the error cases where the log file can't be created, there is a python exception/stack trace that gives enough information for most people to figure out what's wrong. Minor nit, at the point the exception is thrown, anything that was in the log queue is lost, but it probably doesn't matter.
from alarmserver.
We can likely write to the log and fall back to console output if that fails. I'll look at that later.
from alarmserver.
@rct committed a fix for missing logfile to bail out to console.
Edit: Well not missing, but unable to write.
from alarmserver.
The fix now fails if the log file is missing: the logfile does not get created when it doesn't exist on launch.
Instead of using os.access(), which returns False if the file doesn't exist, even if it could be created, the proper way to handle the error conditions should probably be to catch the corresponding exception?!
Here is a diff, also includes a patch to lower the logging level if logging to a file, and only show DEBUG messages when logging to the console:
--- a/core/logger.py
+++ b/core/logger.py
@@ -19,9 +19,9 @@ class DispatchingFormatter:
def start(logfile = None):
#setup logging handler
if logfile:
- if os.access(logfile, os.W_OK):
+ try:
handler = logging.FileHandler(logfile)
- else:
+ except IOError:
handler = logging.StreamHandler()
error("Unable to open %s for writing" % logfile)
else:
@@ -36,7 +36,10 @@ def start(logfile = None):
#setup our handler and log level
logging.getLogger().addHandler(handler)
- logging.getLogger().setLevel(logging.DEBUG)
+ if logfile:
+ logging.getLogger().setLevel(logging.INFO)
+ else:
+ logging.getLogger().setLevel(logging.DEBUG)
start.started = 1
start.started = 0
from alarmserver.
Fixed, in the future a pull request would be appreciated.
from alarmserver.
Related Issues (20)
- Handle unknown TPI response codes gracefully. (tornado) HOT 2
- Handle Zone Bypass Status Message TPI Code 616. HOT 1
- New tornado version doesn't work as iOS Homescreen Web App HOT 5
- Docker support HOT 5
- Envisalink 4 compatibility HOT 10
- Improve envisalink host not found handling. HOT 1
- certfile "" does not exist HOT 2
- Could not get any response - HOT 2
- Understanding plugins, notification system HOT 1
- Implementing custom Keystroke command HOT 17
- Verbose Trouble Status handling
- Is honeywell 20p supportted? HOT 1
- Integration to Athom Homey HOT 1
- install core import httpslistener HOT 4
- Odd issue - switching from stay to away if alarmserver restarts HOT 1
- SSL Error
- Feature Request - Move Pushover Token to alarmserver.cfg
- Issue with Pushover alerts. HOT 2
- RuntimeError: 'maximum recursion depth exceeded in logger after Envisalink firmware upgrade HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alarmserver.