| Home | Trees | Indices | Help |
|
|---|
|
|
1 """
2 Helper code for logging to files.
3
4 All logs that could be used both interactively and from the web server
5 but have group ownership gavo and mode (at least) 664. Only then can
6 both parties write logs.
7
8 The RotatingFileHandler in this module tries to ensure this.
9 """
10
11 #c Copyright 2008-2019, the GAVO project
12 #c
13 #c This program is free software, covered by the GNU GPL. See the
14 #c COPYING file in the source distribution.
15
16
17 import grp
18 import os
19 import warnings
20 from logging import handlers
21
22 from gavo import base
23
24
25 try:
26 GAVO_GROUP_ID = grp.getgrnam(base.getConfig("group"))[2]
27 except KeyError:
28 warnings.warn("Cannot figure out id of group '%s'. Logging will break.")
29 GAVO_GROUP_ID = -1
30
31
33 """logging.handler.RotatingFile with forced group support.
34 """
38
40 # This will fail if we don't own the file. This doesn't hurt as long
41 # as whoever created the file already fixed the permission
42 try:
43 os.chmod(self.stream.name, 0664)
44 os.chown(self.stream.name, -1, GAVO_GROUP_ID)
45 except os.error: # don't worry, see above
46 pass
47
51
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Thu May 2 07:29:09 2019 | http://epydoc.sourceforge.net |