summaryrefslogtreecommitdiff
blob: 4ff0bbf8bdb9a1b5b8d7c156a4a2041d1fc8c2f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
--- edna.py.orig	2007-01-27 18:53:24.000000000 +0000
+++ edna.py	2007-01-27 18:58:38.000000000 +0000
@@ -42,6 +42,7 @@
 import socket
 import re
 import stat
+import syslog
 import random
 import time
 import struct
@@ -144,6 +145,12 @@
           self.log = open(log, 'a')
         except IOError:
           pass
+    else:
+      try:
+        syslog.openlog('edna')
+        self.log = True
+      except:
+        pass
     
     template_path = config.get('server', 'template-dir')
     template_file = config.get('server', 'template')
@@ -254,7 +261,7 @@
             (config.get('server', 'binding-hostname'), self.port),
             EdnaRequestHandler)
     except socket.error, value:
-        self.log_message( "edna: bind(): %s" % str(value[1]) )
+        self.log_message( "bind(): %s" % str(value[1]) )
         raise SystemExit
 
   def server_bind(self):
@@ -290,12 +297,17 @@
     return 0
 
   def log_message(self, msg):
-    if self.log:
-      try:
-        self.log.write(msg + '\n')
-        self.log.flush()
-      except IOError:
-        pass
+      if self.log == True:
+        try:
+           syslog.syslog(msg)
+        except:
+           pass
+      elif self.log:
+        try:
+           self.log.write('edna: ' + msg + '\n')
+           self.log.flush()
+        except IOError:
+           pass
 
   def debug_message(self, msg):
     if debug_level<1:
@@ -1125,21 +1137,21 @@
 
   svr = Server(fname)
   if oggSupport == 'yes':
-    svr.log_message('edna: Ogg Vorbis support enabled')
+    svr.log_message('Ogg Vorbis support enabled')
   else:
-    svr.log_message('edna: Ogg Vorbis support disabled, to enable it you will need to install the "pyogg" and the "pyvorbis" modules')
+    svr.log_message('Ogg Vorbis support disabled, to enable it you will need to install the "pyogg" and the "pyvorbis" modules')
 
-  svr.log_message("edna: serving on port %d..." % svr.port)
+  svr.log_message("serving on port %d..." % svr.port)
   try:
     while running:
 #      print 'waiting ... '
       if config_needed:
-        svr.log_message('edna: Reloading config %s' % fname)
+        svr.log_message('Reloading config %s' % fname)
         svr.server_close()
         svr = Server(fname)
         config_needed  = None
       svr.handle_request()
-    svr.log_message ("edna: exiting")
+    svr.log_message ("exiting")
     sys.exit(0)
   except KeyboardInterrupt:
     print "\nCaught ctr-c, taking down the server"