System logs
Julie Stamp (8365) 474 posts |
I’ve been making a logging module, along the lines of !SysLog and the built-in Select module. To give it a try, you can download from here.
in a task window, and TestLog will appear in your RAM disc (the location is hard-wired at the moment). Written so far are
Logs given message.
Sets the detail level for the given log. A higher number means more messages are recorded.
Loads log options from the given file. The options file can set detail level and also divert to another computer1. Only use divert within your private home network, as such message are transmitted in plain text.
Display the current options for the given log
Display options for all known logs (including default options). and SWI’s
Apps/modules I know of that send to SysLog:
Some applications may say that SysLog has not been seen, in which case “*Set <SysLog$Dir> RAM:$” should keep them happy. Please try any applications you have that work with SysLog, or use some of the commands above, and let me know how it is. 1 When sending logs to another computer, they are sent by UDP to port 514. Messages are in RFC 5424 ‘IETF’ format. They can be received on Linux using syslog-ng or similar. |
Steve Pampling (1551) 8172 posts |
Looking OK. First test abusing the old SysLog “Test” works nicely (once the SysLog_IRQMode call is REM’d out) |
Julie Stamp (8365) 474 posts |
The module name/version I chose so that existing applications would be ok with it.
So, about that. I put off all my flushing (writing to files, network) till callbacks; effectively you’re always running with IRQMode on. I guess this could mean some messages get lost if you had lots of uninterrupted SVC mode logging or were trying to debug a SVC mode crash (sounds like a case for Reporter or DADebug). I would like to hear about any other code that uses IRQMode or the other more advanced SWI’s. I saw EtherUSB can call SysLog, but I don’t know how I persuade it to do that.
Abusing the Test that comes with !SysLog (100000 messages) when logging over UDP annoys RPCEmu, saying “Too many open files” (but not when logging to a file??). I don’t know where the problem lies on that one. |
Colin (478) 2433 posts |
You only get syslog output from etherusb with the debug version of the module. The swis used are in etherusb.c.utils |
Steve Pampling (1551) 8172 posts |
Now there’s an interesting question, or multiples. I wonder is that filling the buffer space on the RO stack or on the RPCEmu network stack? (guessing you’ve got the NAT setup) |
Julie Stamp (8365) 474 posts |
Yes NAT. After doing the 100000 messages, on the RISC OS side there are no open files, and three open internet sockets (not opened by me). On the Linux side, RPCEmu has open 999 UDP sockets. I don’t know if that’s deliberate or not. Each flush of the log buffer does
|
Timothy Baldwin (184) 242 posts |
When sendto() is called on a UDP socket that does not have any local port set, a local port number is assigned. Reuse the socket, rather than create a new one each time. This results the same local port number being used, allowing and requiring the NAT implementation in RPCEmu to reuse sockets. This will help with any NAT and stateful firewall. |
Julie Stamp (8365) 474 posts |
Time for some Sunday afternoon SysLog. The latest download is here As well as fixing the socket problem upthread, this adds
which immediately flushes the named log, and
which immediately flushes all logs. The logs are now written (if local) to <System$LogDir>; an obeyfile is included in the test archive to set the log directory. The periodic flush task is started automatically when entering the desktop. This means that you can start SysLog in your boot sequence, by copying into !System.500.Modules.Test and adding
to the end of Choices.Boot.PreDesktop |
Julie Stamp (8365) 474 posts |
If you have a Linux computer with syslog-ng, you can try out the remote logging by adding the following to /etc/syslog-ng/syslog-ng.conf:
and of course put a
line in your syslog client options file (replacing 192.168.0.1 with the address or name of your server). Then you can for example do *ReportOpt SysLog and see all of the Reporter output appear on your Linux computer. |
Steve Pampling (1551) 8172 posts |
and of course put a I don’t have a setup to test, but would that work with |
Julie Stamp (8365) 474 posts |
Yes it does :-) |
Steve Pampling (1551) 8172 posts |
My kind of person – I have an intense dislike of embedded IPs even if they sit in a config file1. The IPs of everything I get near are whatever the DHCP server hands out and the method of access is by name. Oops, my NAS is reporting disk errors in part of the RAID. Stuff to do. 1 I have a long-running battle with medical equipment suppliers (a couple in particular) where they persist in doing 20th Century stuff. 2 Like when a company configures client devices on the local network (domain1) to query for TheServer – which is interpreted by local systems as TheServer.domain1, and up the road at another hospital(domain2) interpreted as TheServer.domain2. A failure to connect is noted. This of course is our firewall at fault, rather than inept configuration of the client. No, IP would not be the answer as the NAT makes that different depending on where the client is. |
Matthew Phillips (473) 721 posts |
I am dealing with a nasty application crash where the whole machine gets thoroughly stiffed, and SysLog likes like it would be very useful. I have managed to set up syslog-ng on a Linux machine and after a bit of puzzling things out I’ve got it working across my network. To hook it into my application’s existing debugging code it would probably be best to use the SWIs rather than the star command. Can you point me to documentation for SysLog_LogMessage and SysLog_Flush please? |
Matthew Phillips (473) 721 posts |
Don’t worry. I have located a version of !SysLog on our Risc PC, complete with documentation and C veneers. That should be enough to get me started. |
Colin Ferris (399) 1818 posts |
Just as a note- Andy S of ‘Paint update’ – modified RPCEmu to output ‘I think’ Function names to a file. |
Julie Stamp (8365) 474 posts |
For future reference, here’s what I’ve implemented:
|
Andy S (2979) 504 posts |
Just as a note- Andy S of ‘Paint update’ – modified RPCEmu to output ‘I think’ Function names to a file. I didn’t get as far as retrieving function names, though that would be very useful. It just logs the address of the function and the contents of the registers. It’s painfully slow because it only works with the interpreted ARM emulation. |