unix.lsp / unix:syslog, example please

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
Locked
Darth_Severus
Posts: 18
Joined: Fri Aug 08, 2014 6:08 pm

unix.lsp / unix:syslog, example please

Post by Darth_Severus »

I tried using unix:syslog from here http://www.newlisp.org/code/modules/unix.lsp.html

I don't know what printf format means, though I read the wikipedia entry.

All of these examples

Code: Select all

(module "unix.lsp") (unix:syslog 5 "test %s")
(module "unix.lsp") (unix:syslog 5 "test%s")
(module "unix.lsp") (unix:syslog 5 "%s test")
(module "unix.lsp") (unix:syslog 5 "test" "%s")
(module "unix.lsp") (unix:syslog 5 "%s" "test")
give me a Segmentation fault, others as well.

I already added "/usr/lib/i386-linux-gnu/libc.so" ; Linux
to /usr/local/share/newlisp-10.6.2/modules/unix.ls

TedWalther
Posts: 608
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC
Contact:

Re: unix.lsp / unix:syslog, example please

Post by TedWalther »

Which version of Linux?
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence. Nine months later, they left with a baby named newLISP. The women of the ivory towers wept and wailed. "Abomination!" they cried.

ralph.ronnquist
Posts: 228
Joined: Mon Jun 02, 2014 1:40 am
Location: Melbourne, Australia

Re: unix.lsp / unix:syslog, example please

Post by ralph.ronnquist »

Seems it gets somewhat happier including %d and %m in the format; i.e.

Code: Select all

(unix:syslog 5 "%d %m")
Doing so at least avoids the vprintf crash (Ubuntu 14.04.3 64bit), but the message is still garbled.

Basically, from experimenting it appears that the format string can be without indicators, or it should include %d as first indicator, and then optionally %m, which results in the system error string.

The first syslog argument doesn't seem to be of much use except of making the format string the second argument. Though I haven't really explored it much.

Additional format indicators didn't seem to work too well.

Darth_Severus
Posts: 18
Joined: Fri Aug 08, 2014 6:08 pm

Re: unix.lsp / unix:syslog, example please

Post by Darth_Severus »

TedWalther wrote:Which version of Linux?
MX Linux (32 Bit)
3.14-0.bpo.2-686-pae #1 SMP Debian 3.14.15-2~bpo70+1 (2014-08-21) i686 GNU/Linux

@ralf: The string needs to be in printf, not the number.
syntax: (unix:syslog num-priority str-message ...)
parameter: num-priority - The priority of the message.
parameter: str-message - The message string and template in printf format.

Darth_Severus
Posts: 18
Joined: Fri Aug 08, 2014 6:08 pm

Re: unix.lsp / unix:syslog, example please

Post by Darth_Severus »

It's based on Debian 8.2

TedWalther
Posts: 608
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC
Contact:

Re: unix.lsp / unix:syslog, example please

Post by TedWalther »

Thanks Darth.
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence. Nine months later, they left with a baby named newLISP. The women of the ivory towers wept and wailed. "Abomination!" they cried.

Locked