Sysops Notepad

[Python] fluent-logger-python 본문

업무/dev

[Python] fluent-logger-python

sysops 2019. 1. 25. 15:22
728x90

1. pip install fluent-logger


2. FluentSender Interface


from fluent import sender

from fluent import event

logger = sender.FluentSender('app', host='host', port=24224)


logger.emit('follow', {

  'from': 'userA',

  'to':   'userB'

})



if not logger.emit('follow', {'from': 'userA', 'to': 'userB'}):

    print(logger.last_error)

    logger.clear_last_error() # clear stored error after handled errors



cur_time = int(time.time())

logger.emit_with_time('follow', cur_time, {'from': 'userA', 'to':'userB'})


logger.close()


3 .Event-Based Interface


from fluent import sender


# for local fluent

sender.setup('app')


# for remote fluent

sender.setup('app', host='host', port=24224)

event.Event('follow', {

  'from': 'userA',

  'to':   'userB'

})


sender.get_global_sender 

sender.close 



참고:

https://github.com/fluent/fluent-logger-python

728x90
Comments