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

Log to file #83

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 12 additions & 4 deletions autoload/vam.vim
Expand Up @@ -51,9 +51,14 @@ let s:c['pool_item_check_fun'] = get(s:c, 'pool_item_check_fun', 'none')
" to show more requests by Vim
" TODO: move log code into other file (such as utils.vim) because its not used on each startup
" TODO: think about autowriting it
let s:c['log_to_buf'] = get(s:c, 'log_to_buf', 0)
let s:c['vam_log_buffer_name'] = get(s:c, 'vam_log_buffer_name', s:c.plugin_root_dir.'/VAM_LOG.txt')
let s:c['log_to_buf'] = get(s:c, 'log_to_buf', 0)
let s:c['log_to_file'] = get(s:c, 'log_to_file', 0)
let s:c['log_name'] = get(s:c, 'log_name', s:c.plugin_root_dir.'/VAM_LOG.txt')

if s:c['log_to_file'] == 1
let s:c['log_lines'] = []
call system('touch '.s:c['log_name'])
endif
" More options that are used for plugins’ installation are listed in
" autoload/vam/install.vim

Expand Down Expand Up @@ -388,8 +393,11 @@ endfun

" looks like an error but is not. Catches users attention. Logs to :messages
fun! vam#Log(s, ...)
if s:c.log_to_buf
silent! exec 'e '.fnameescape(s:c.vam_log_buffer_name)
if s:c.log_to_file
cal add(s:c.log_lines, a:s)
cal writefile(s:c.log_lines, s:c.log_name)
elseif s:c.log_to_buf
silent! exec 'e '.fnameescape(s:c.log_name)
cal append('$', split(a:s, "\n", 1))
else
let hi = a:0 > 0 ? a:1 : 'WarningMsg'
Expand Down
28 changes: 15 additions & 13 deletions doc/vim-addon-manager-getting-started.txt
Expand Up @@ -397,29 +397,31 @@ Also see https://github.com/MarcWeber/vim-addon-manager/issues/77:
\}
<

and possibly log_to_buf which will prevent you from having to deal with most
of those "hit enter to continue" prompts while VAM downloads plugins
and possibly log_to_buf or log_to_file which will prevent you from having
to deal with most of those "hit enter to continue" prompts while VAM
downloads plugins.

Also see https://github.com/MarcWeber/vim-addon-manager/issues/79:
>
let g:vim_addon_manager = {
\'shell_commands_run_method': 'system',
\'auto_install': 1,
\'log_to_buf': 1,
\}
<
If you set log_to_buf to 1 then VAM logging output will be subsequently
visible in your screen as the first open buffer after the plugin
installations are complete. You should be able to save this output
with a simple :w

If you set log_to_file to 1 then VAM logging output will invisble and
instead sent to an actual file on disk.

and if you wish, you may customize the location of the VAM log file, just
use the vam_log_buffer_name option which defaults to a value of VAM_LOG.txt
You may customize the location of the VAM log file, just
use the log_name option which defaults to a value of VAM_LOG.txt
in the VAM plugin's root directory e.g.
~/.vim/vim-addons/vim-addon-manager/VAM_LOG.txt
>
let g:vim_addon_manager = {
\'shell_commands_run_method': 'system',
\'auto_install': 1,
\'log_to_buf': 1,
\'vam_log_buffer_name': '/tmp/vam_install.log',
\'log_name': '/tmp/vam_install.log',
\}
<

Also see https://github.com/MarcWeber/vim-addon-manager/issues/79:

vim: tw=78:ts=8:ft=help:norl