lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

It was thus said that the Great Michal Kolodziejczyk once stated:
> On 26.11.2013 23:46, Justin Cormack wrote:
> >>   I'm not trying to shoot your idea down, but there are issues I think you
> >> missed.
> >>
> > 
> > We are going to brutally decide on a best interface and officialize it.
> > Somehow. But its going to happen...
> Exactly that I am sure that if such a common set of "blessed libraries"
> is to emerge, then it has to have some assumptions, for example: all
> modules return tables. I think the first step would be to design common
> API. Then, if I really want "incompatible" modules to enter this
> ecosystem, I would write wrappers to make them compatible with this API.
> Of course there is a question: how to design this common set of
> interfaces. I think either there will be a leader with a clear vision of
> this (any volunteer?), or it will be voted for by the community (slow
> process with lots of iterations :( ).
> So, in short: focus on API first, then map it on concrete
> implementations. So I do propose a "top-down" approach rather than
> "bottom-up" (trying to unite all existing implementations into common
> API - probably imposibble).

  So how does this work?  

  Something like ...

  I propose an interface to syslog (RFC-3164).  The table returned shall
have the following functions:

		level = one of
			'crit' or 'critical'
			'emerge' or 'emergency'
			'err' or 'error'
			'info' or 'information'
			'warn' or 'warning'

		message, a string, uses format string as string.format()
		other parameters

		id = string
		facility = one of
			'local0' to 'local7'
		options = table, with the following fields (not all
			pid 	boolean, log PID
			cons	boolean, log to console
			nodelay	boolean, open connection immediately
			odelay	boolean, wait to open connection
			nowait	boolean, immediately log

		Close a connection to the syslog daemon

	setlogmask(level, ... )

		only log listed levels (see log() for list of levels) to
		syslog.  Levels not listed will not generate an entry.

  The table returned shall have the __call metamethod defined, which will be
equivilent to 'log(...)'.  

  If people want functions in the form of foo.error(), they can be written

	log = {}
	for _,name in ipairs { 'alert' , 'critical' , 'debug' , 'emergency' , 'error' , 'info' , 'notice' , 'warn' } do
	  log[name] = function(...) syslog(name,...) end