malinkinsa / asyncgelf Goto Github PK
View Code? Open in Web Editor NEWAsync library to send logs to graylog in GELF (Graylog Extended Log Format) format.
License: MIT License
Async library to send logs to graylog in GELF (Graylog Extended Log Format) format.
License: MIT License
Is your feature request related to a problem? Please describe.
For lightweight setups we'd want to minimize dependencies. Technically 'httpx' is only required for HTTP handler but not for TCP and UDP.
Describe the solution you'd like
Wrap 'httpx' import into try..except
and remove from required dependencies.
Describe alternatives you've considered
No.
Additional context
No.
Hello,
I've successfully used your library.
I just had to make a modification that could be interesting to add to the default one.
The timestamp parameter
In the GELF documentation there is this parameter that is crucial to have them nicely saved on graylog.
As I've used this library to ingest old logs I wanted to forcefeed the timestamp into the GELF.
I had to add in the library the timestamp in
def init
with Optional[int] =None
self.timestamp=timestamp
gelf_message = {... 'timestamp':self.timestamp}
In my code I've used int(datetime.strptime(<variable_from_log>, <timeformat>).timestamp())
to get the right format of my original time from the log. It worked.
I was just wondering if there is a more "elegant" way to integrate it in the library.
Thanks
Describe the bug
(
asyncgelf/asyncgelf/asyncgelf.py
Line 262 in 8054a37
in the line above sync call from async happens.
To Reproduce
Minimal code example:
import asyncio
import asyncgelf
handler = asyncgelf.GelfUdp(host='127.0.0.1')
asyncio.run(handler.udp_handler({'text': 'yo!'}))
Expected behavior
Actually I think that it's also extremely useful to have both sync and async interfaces. So the expected behaviour is sync calls to happen synchronously and async to happen asynchronously.
Additional context
So the current implementation for GelfUdp from what I can see is pretty much sync, and the GelfUdp.make_gelf_chunks()
is sync as well.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.