omrikiei / aws_logging_handlers

AWS integration for python logging handlers(S3, Kinesis)
https://omrikiei.github.io/aws_logging_handlers/
MIT License
71 stars 27 forks source link

Support for dynamic filename (Include directory) #14

Open pimtel opened 5 years ago

pimtel commented 5 years ago

Hi,

I'm dealing with a situation that this library does not cover. I want to structure my logging using Hive partition on S3 to be consumed by other applications. So I need a way to build the S3 file path dynamically like that:

def get_dynamic_path(date):
    # Will return /year=2019/month=06/day=19/20190619.json
    return date.strftime('/year=%Y/month=%m/day=%d/%s')

s3_handler = S3Handler(dynamic_filename=get_dynamic_path)

Would be nice if I could pass my own function to S3Handler to build dynamically the path.