Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maktaba should offer a simple log handler #141

Open
malcolmr opened this issue Mar 23, 2015 · 4 comments
Open

Maktaba should offer a simple log handler #141

malcolmr opened this issue Mar 23, 2015 · 4 comments
Assignees

Comments

@malcolmr
Copy link
Member

Maktaba's logging is useful, but unless I'm missing something, there's easy no way to use it out of the box, as you need your own log handler before it'll do anything.

We don't want to install a log handler by default, but it would be useful to provide an optional maktaba#log#InstallSimpleLogHandler() that adds a handler that accumulates log records into a (user-specified?) limited-size list, along with a maktaba#log#GetSimpleLogHandlerRecords() or similar.

@dbarnett
Copy link
Contributor

You can get it with two hacky lines of vimscript:

let g:maktaba_log = []
call maktaba#log#AddHandler(maktaba#function#FromExpr('add(g:maktaba_log, a:000)'), 1)

The real answer is to publish a simple plugin to receive and display the logs. We can document that hack to get it in the meantime, or maybe we could add something like maktaba#log#NewReceiverList([with_recent]) -> list to get that down to

let g:maktaba_log = maktaba#log#NewReceiverList(1)

I don't think bounding it will be that big a deal either, at least for the short-term solution.

@malcolmr
Copy link
Member Author

A logging plugin would certainly be nice, but I was thinking of something that would be available to someone just using Maktaba.

I like the idea of providing something simple. I think what you're proposing with NewReceiverList() is effectively the combination of the two things I suggested? (I'm not sure a name like IfNecessaryInstallNewTrivialLogHandlerAndAnywayReturnLogEntries() is entirely sensible, but those are the semantics we're talking about, right?)

Is there any reason a casual caller wouldn't want the recent log entries?

@dbarnett
Copy link
Contributor

Almost. The list reference would be updated as new messages come in.

But actually, something like maktaba#log#DumpRecentEntries() could just return a copy of s:log_queue. Then users just have to bump the 'history' setting early if they want to not lose early log entries (a message in the log tells them so).

BTW, don't want to optimize for the no-logging-plugin case too much, because reading entries from a vimscript list is pretty awkward and the plugin is very small. We thought about including more of a user interface in maktaba but it didn't fit well for a library.

@dbarnett
Copy link
Contributor

I also noticed maktaba doesn't shout warning and error logging to the user as messages come in (#185). That part should be pretty easy to make built-in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants