mirror of
https://github.com/nicolargo/glances.git
synced 2024-11-28 14:12:21 +03:00
R/W error with the glances.log file (issue #474)
This commit is contained in:
parent
0bd5993a66
commit
4d1ef9bba4
6
NEWS
6
NEWS
@ -5,6 +5,8 @@ Glances Version 2.x
|
||||
Version 2.3
|
||||
===========
|
||||
|
||||
Enhancements and news features:
|
||||
|
||||
* Add actions on alerts (issue #132). It is now possible to run action (command line) by triggers. Action could containq {Mustache} {{tag}} (Mustache) with stat value.
|
||||
* Add InfluxDB export module (--export-influxdb) (issue #455)
|
||||
* Add Statsd export module (--export-statsd) (issue #465)
|
||||
@ -13,6 +15,10 @@ Version 2.3
|
||||
* Add the RAID plugin (issue #447)
|
||||
* Add the Docker plugin (issue #440)
|
||||
|
||||
Bugs corrected:
|
||||
|
||||
* R/W error with the glances.log file (issue #474)
|
||||
|
||||
Version 2.2.1
|
||||
=============
|
||||
|
||||
|
@ -332,6 +332,8 @@ By default, the log file is under:
|
||||
:Linux, \*BSD and OS X: ``/tmp/glances.log``
|
||||
:Windows: ``%APPDATA%\Local\temp\glances.log``
|
||||
|
||||
If glances.log is not writable, a new file will be created and returned to the user console.
|
||||
|
||||
Anatomy Of The Application
|
||||
==========================
|
||||
|
||||
|
@ -71,14 +71,27 @@ LOGGING_CFG = {
|
||||
}
|
||||
|
||||
|
||||
def tempfile_name():
|
||||
"""Return the tempfile name (full path)"""
|
||||
ret = os.path.join(tempfile.gettempdir(), 'glances.log')
|
||||
if os.access(ret, os.F_OK) and not os.access(ret, os.W_OK):
|
||||
print("Warning: can't write logs to file {} (permission denied)".format(ret))
|
||||
ret = tempfile.mkstemp(prefix='glances', suffix='.tmp', text=True)
|
||||
print("Create a new log file: {}".format(ret[1]))
|
||||
return ret[1]
|
||||
|
||||
|
||||
def glances_logger():
|
||||
"""Build and return the logger"""
|
||||
temp_path = tempfile_name()
|
||||
_logger = logging.getLogger()
|
||||
try:
|
||||
LOGGING_CFG['handlers']['file']['filename'] = temp_path
|
||||
logging.config.dictConfig(LOGGING_CFG)
|
||||
except AttributeError:
|
||||
# dictConfig is only available for Python 2.7 or higher
|
||||
# Minimal configuration for Python 2.6
|
||||
logging.basicConfig(filename=os.path.join(tempfile.gettempdir(), 'glances.log'),
|
||||
logging.basicConfig(filename=temp_path,
|
||||
level=logging.DEBUG,
|
||||
format='%(asctime)s -- %(levelname)s -- %(message)s')
|
||||
return _logger
|
||||
|
Loading…
Reference in New Issue
Block a user