Repository navigation
Conversation
|
Review comments from @glyph addressed in push c5caa41:
addressed in push 6881912:
This still leaves:
I would prefer to use Twisted's nonblocking implementation, but I'm not sure how exactly, so I chose to simply use a socket for now. I will look into it again. rSyslog is allowed over TCP as well, so a solution should work with both transports. |
0c7e4c6 to
da5b27f
Compare
0852967 to
7bfbc26
Compare
df3527a to
5c24857
Compare
|
I'm setting this branch to reviewable, because I need some help with the tests, please. I don't understand how I can fake a reactor for my use case. The CI also wants me to add MyPy type hints - something I am failing at (and could use some hints for) as well :| pinging @glyph, since you already looked at the original issue. |
glyph
left a comment
There was a problem hiding this comment.
This wasn't getting looked at because I tend to exclude things with failing tests when I look at the review queue. Let's maybe find some time to pair program on this, if you have any, or if not, I'll have to look at this myself later; let me know.
No worries about the delay.
I'd love to! |
twm
left a comment
There was a problem hiding this comment.
This caught my eye, but I haven't done a full review, so just leaving comments.
Thanks for giving this a go!
| @implementer(ILogObserver) | ||
| class RemoteSyslogObserver: | ||
| """ | ||
| Log observer that forwards to a remote syslog server. |
There was a problem hiding this comment.
Could you elaborate on the particular RFC that it implements, as there are several syslog variants?
The module name suggests that this is compatible with the common rsyslog implementation --- if that's not the case, best to clarify.
There was a problem hiding this comment.
i've implemented this following the original rfc3164 (n.b. the timestamp format and limiting log lines to 1k bytes). it is compatible with rsyslog, that was the whole reason we needed this module.
i have added the rfc number to the RemoteSyslogObserver docstring.
There was a problem hiding this comment.
i have prepared a patch to switch between traditional and standardized formatting. i'd rather submit that in a later review round, so we can focus on the big stuff (zope interface, reactor, etc) first.
| leader + message, | ||
| ) | ||
|
|
||
| self.handler.send(d.encode(self.encoding, "ignore")[:1024]) |
There was a problem hiding this comment.
The docstring should mention this 1024-byte limit. It should probably be a class variable so that it can be overridden like:
o = RemoteSyslogObserver(...)
o.maxDatagramBytes = 2048However, this behavior may actually belong in the UDPSyslog class, since the length limit is an attribute of the transport.
| 514. | ||
|
|
||
| @type handler: C{IProtocol} | ||
| @param handler: Class implementing C{UDPSyslog}. |
There was a problem hiding this comment.
It is a bit odd to say "implementing" when UDPSyslog isn't a Zope interface.
I think that you should define an actual interface (it should be pretty trivial) and accept an implementation of it, rather than a class that this constructor instantiates with the server and port arguments. That would:
- Move the I/O of calling
reactor.listenUDP()out of this constructor, which would make it easy to pass an in-memory implementation in your test suite. - Allow future extension of
UDPSyslog(e.g., ability to set the bound port or interface) without plumbing through additional arguments in this constructor. - Allow other future implementations, such as over TCP or DTLS.
If you want a convenience constructor for the UDP case you could define a module-level function or a classmethod.
There was a problem hiding this comment.
Is this what you had in mind? 4678588 (this commit is not final, i'll rebase it before this is done)
| reactor.listenUDP(0, self) | ||
|
|
||
| def send(self, data: bytes) -> None: | ||
| self.transport.write(data, self.address) |
There was a problem hiding this comment.
I don't think that this is actually safe --- unlike most of Twisted, the logging subsystem can be used from any thread, not just the reactor thread, so you probably need a reactor.callFromThread() in here somewhere.
|
Hi, I appreciate your input! I've quickly worked on some of the smaller items. I'll have to do some research before i'll tackle the others. will keep you posted! |
Scope and purpose
Fixes #12464
The twisted.python.syslog.SyslogObserver can only forwards logs to the local syslog (which is fine per se). RemoteSyslogObserver directly sends Syslog messages over the network, without going through local syslog.