예제 #1
0
파일: script.py 프로젝트: ienliven/flocker
 def postOptions(self):
     if self['journald']:
         destination = JournaldDestination()
     else:
         if self['logfile'] is None:
             logfile = self._sys_module.stdout
         else:
             logfilepath = FilePath(self['logfile'])
             logfilepath_directory = logfilepath.parent()
             if not logfilepath_directory.exists():
                 logfilepath_directory.makedirs()
             # A twisted.python.logfile which has write and flush methods
             # but which also rotates the log file.
             logfile = LogFile.fromFullPath(
                 logfilepath.path,
                 rotateLength=LOGFILE_LENGTH,
                 maxRotatedFiles=LOGFILE_COUNT,
             )
         destination = FileDestination(file=logfile)
     self.eliot_destination = destination
     original_postOptions(self)
예제 #2
0
"""
Write some logs to journald.
"""

from __future__ import print_function

from eliot import log_message, start_action, add_destinations
from eliot.journald import JournaldDestination

add_destinations(JournaldDestination())


def divide(a, b):
    with start_action(action_type="divide", a=a, b=b):
        return a / b


print(divide(10, 2))
log_message(message_type="inbetween")
print(divide(10, 0))