Apache/2.4.7 (Ubuntu) Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) safemode : OFF MySQL: ON | Perl: ON | cURL: OFF | WGet: ON > / usr / lib / python2.7 / dist-packages / landscape / | server ip : 104.21.89.46 your ip : 172.70.126.55 H O M E |
Filename | /usr/lib/python2.7/dist-packages/landscape/log.py |
Size | 1.6 kb |
Permission | rw-r--r-- |
Owner | root : root |
Create time | 27-Apr-2025 09:56 |
Last modified | 20-Feb-2014 23:01 |
Last accessed | 06-Jul-2025 10:42 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
import inspect
import logging
def format_object(object):
"""
Returns a fully-qualified name for the specified object, such as
'landscape.log.format_object()'.
"""
if inspect.ismethod(object):
# FIXME If the method is implemented on a base class of
# object's class, the module name and function name will be
# from the base class and the method's class name will be from
# object's class.
name = repr(object).split(" ")[2]
return "%s.%s()" % (object.__module__, name)
elif inspect.isfunction(object):
name = repr(object).split(" ")[1]
return "%s.%s()" % (object.__module__, name)
return "%s.%s" % (object.__class__.__module__, object.__class__.__name__)
def format_delta(seconds):
if not seconds:
seconds = 0.0
return "%.02fs" % float(seconds)
def format_percent(percent):
if not percent:
percent = 0.0
return "%.02f%%" % float(percent)
def rotate_logs():
"""
This closes and reopens the underlying files in the logging module's
root logger. If called after logrotate (or something similar) has
moved the old log file out of the way, this will start writing to a new
new log file...
"""
for handler in logging.getLogger().handlers:
if isinstance(handler, logging.FileHandler):
handler.acquire()
try:
handler.stream.close()
handler.stream = open(handler.baseFilename,
handler.mode)
finally:
handler.release()
logging.info("Landscape Logs rotated")
import logging
def format_object(object):
"""
Returns a fully-qualified name for the specified object, such as
'landscape.log.format_object()'.
"""
if inspect.ismethod(object):
# FIXME If the method is implemented on a base class of
# object's class, the module name and function name will be
# from the base class and the method's class name will be from
# object's class.
name = repr(object).split(" ")[2]
return "%s.%s()" % (object.__module__, name)
elif inspect.isfunction(object):
name = repr(object).split(" ")[1]
return "%s.%s()" % (object.__module__, name)
return "%s.%s" % (object.__class__.__module__, object.__class__.__name__)
def format_delta(seconds):
if not seconds:
seconds = 0.0
return "%.02fs" % float(seconds)
def format_percent(percent):
if not percent:
percent = 0.0
return "%.02f%%" % float(percent)
def rotate_logs():
"""
This closes and reopens the underlying files in the logging module's
root logger. If called after logrotate (or something similar) has
moved the old log file out of the way, this will start writing to a new
new log file...
"""
for handler in logging.getLogger().handlers:
if isinstance(handler, logging.FileHandler):
handler.acquire()
try:
handler.stream.close()
handler.stream = open(handler.baseFilename,
handler.mode)
finally:
handler.release()
logging.info("Landscape Logs rotated")