mirror of
https://github.com/tstack/lnav.git
synced 2024-09-11 13:05:51 +03:00
parent
07cc749c50
commit
9a05b9d186
4
NEWS
4
NEWS
@ -16,6 +16,10 @@ lnav v0.8.6:
|
||||
and a message is printed to the console indicating the file name.
|
||||
* In time-offset mode, the deltas for messages before the first mark
|
||||
are now negative instead of relative to the start of the log.
|
||||
* The $XDG_CONFIG_HOME environment variable (or ~/.config directory) are
|
||||
now respected for storing lnav's configuration. If you have an existing
|
||||
~/.lnav directory, that will continue to be used until you move it to
|
||||
$XDG_CONFIG_HOME/lnav or ~/.config/lnav.
|
||||
|
||||
Fixes:
|
||||
* Added 'notice' log level.
|
||||
|
@ -195,6 +195,7 @@ void log_host_info()
|
||||
log_info(" jittarget=%s", jittarget);
|
||||
log_info("Environment:");
|
||||
log_info(" HOME=%s", getenv("HOME"));
|
||||
log_info(" XDG_CONFIG_HOME=%s", getenv("XDG_CONFIG_HOME"));
|
||||
log_info(" LANG=%s", getenv("LANG"));
|
||||
log_info(" PATH=%s", getenv("PATH"));
|
||||
log_info(" TERM=%s", getenv("TERM"));
|
||||
|
@ -2628,7 +2628,7 @@ int main(int argc, char *argv[])
|
||||
auto home = getenv("HOME");
|
||||
auto path_str = stdin_tmp_path.str();
|
||||
|
||||
if (startswith(path_str, home)) {
|
||||
if (home != nullptr && startswith(path_str, home)) {
|
||||
path_str = path_str.substr(strlen(home));
|
||||
if (path_str[0] != '/') {
|
||||
path_str.insert(0, 1, '/');
|
||||
|
@ -76,12 +76,31 @@ lnav_config_listener *lnav_config_listener::LISTENER_LIST;
|
||||
filesystem::path dotlnav_path()
|
||||
{
|
||||
auto home_env = getenv("HOME");
|
||||
auto xdg_config_home = getenv("XDG_CONFIG_HOME");
|
||||
|
||||
if (home_env) {
|
||||
if (home_env != nullptr) {
|
||||
auto home_path = filesystem::path(home_env);
|
||||
|
||||
if (home_path.is_directory()) {
|
||||
return home_path / ".lnav";
|
||||
auto home_lnav = home_path / ".lnav";
|
||||
|
||||
if (home_lnav.is_directory()) {
|
||||
return home_lnav;
|
||||
}
|
||||
|
||||
if (xdg_config_home != nullptr) {
|
||||
auto xdg_path = filesystem::path(xdg_config_home);
|
||||
|
||||
return xdg_path / "lnav";
|
||||
}
|
||||
|
||||
auto home_config = home_path / ".config";
|
||||
|
||||
if (home_config.is_directory()) {
|
||||
return home_config / "lnav";
|
||||
}
|
||||
|
||||
return home_lnav;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "lnav_config.hh"
|
||||
#include "pcrepp/pcrepp.hh"
|
||||
#include "shlex.hh"
|
||||
#include "auto_mem.hh"
|
||||
@ -392,6 +393,38 @@ int readline_context::command_complete(int count, int key)
|
||||
return rl_insert(count, key);
|
||||
}
|
||||
|
||||
readline_context::readline_context(const std::string &name,
|
||||
readline_context::command_map_t *commands,
|
||||
bool case_sensitive)
|
||||
: rc_name(name),
|
||||
rc_case_sensitive(case_sensitive),
|
||||
rc_quote_chars("\"'"),
|
||||
rc_highlighter(nullptr)
|
||||
{
|
||||
char *home;
|
||||
|
||||
if (commands != nullptr) {
|
||||
command_map_t::iterator iter;
|
||||
|
||||
for (iter = commands->begin(); iter != commands->end(); ++iter) {
|
||||
std::string cmd = iter->first;
|
||||
|
||||
this->rc_possibilities["__command"].insert(cmd);
|
||||
iter->second->c_func(INIT_EXEC_CONTEXT, cmd, this->rc_prototypes[cmd]);
|
||||
}
|
||||
}
|
||||
|
||||
memset(&this->rc_history, 0, sizeof(this->rc_history));
|
||||
history_set_history_state(&this->rc_history);
|
||||
|
||||
auto config_dir = dotlnav_path();
|
||||
auto hpath = (config_dir / this->rc_name) + ".history";
|
||||
read_history(hpath.str().c_str());
|
||||
this->save();
|
||||
|
||||
this->rc_append_character = ' ';
|
||||
}
|
||||
|
||||
readline_curses::readline_curses()
|
||||
: rc_active_context(-1),
|
||||
rc_child(-1),
|
||||
@ -739,22 +772,15 @@ void readline_curses::start()
|
||||
}
|
||||
}
|
||||
|
||||
auto config_dir = dotlnav_path();
|
||||
std::map<int, readline_context *>::iterator citer;
|
||||
for (citer = this->rc_contexts.begin();
|
||||
citer != this->rc_contexts.end();
|
||||
++citer) {
|
||||
char *home;
|
||||
|
||||
citer->second->load();
|
||||
home = getenv("HOME");
|
||||
if (home) {
|
||||
char hpath[2048];
|
||||
|
||||
snprintf(hpath, sizeof(hpath),
|
||||
"%s/.lnav/%s.history",
|
||||
home, citer->second->get_name().c_str());
|
||||
write_history(hpath);
|
||||
}
|
||||
auto hpath = (config_dir / citer->second->get_name()) + ".history";
|
||||
write_history(hpath.str().c_str());
|
||||
citer->second->save();
|
||||
}
|
||||
|
||||
|
@ -88,41 +88,8 @@ public:
|
||||
typedef std::map<std::string, command_t *> command_map_t;
|
||||
|
||||
readline_context(const std::string &name,
|
||||
command_map_t *commands = NULL,
|
||||
bool case_sensitive = true)
|
||||
: rc_name(name),
|
||||
rc_case_sensitive(case_sensitive),
|
||||
rc_quote_chars("\"'"),
|
||||
rc_highlighter(nullptr)
|
||||
{
|
||||
char *home;
|
||||
|
||||
if (commands != nullptr) {
|
||||
command_map_t::iterator iter;
|
||||
|
||||
for (iter = commands->begin(); iter != commands->end(); ++iter) {
|
||||
std::string cmd = iter->first;
|
||||
|
||||
this->rc_possibilities["__command"].insert(cmd);
|
||||
iter->second->c_func(INIT_EXEC_CONTEXT, cmd, this->rc_prototypes[cmd]);
|
||||
}
|
||||
}
|
||||
|
||||
memset(&this->rc_history, 0, sizeof(this->rc_history));
|
||||
history_set_history_state(&this->rc_history);
|
||||
home = getenv("HOME");
|
||||
if (home) {
|
||||
char hpath[2048];
|
||||
|
||||
snprintf(hpath, sizeof(hpath),
|
||||
"%s/.lnav/%s.history",
|
||||
home, this->rc_name.c_str());
|
||||
read_history(hpath);
|
||||
this->save();
|
||||
}
|
||||
|
||||
this->rc_append_character = ' ';
|
||||
};
|
||||
command_map_t *commands = nullptr,
|
||||
bool case_sensitive = true);
|
||||
|
||||
const std::string &get_name() const { return this->rc_name; };
|
||||
|
||||
|
@ -4,7 +4,7 @@ lnav_test="${top_builddir}/src/lnav-test"
|
||||
|
||||
export HOME="./meta-sessions"
|
||||
rm -rf "./meta-sessions"
|
||||
mkdir -p $HOME
|
||||
mkdir -p $HOME/.config
|
||||
|
||||
run_test ${lnav_test} -n \
|
||||
-c ":comment Hello, World!" \
|
||||
@ -21,6 +21,16 @@ check_output ":tag did not work?" <<EOF
|
||||
192.168.202.254 - - [20/Jul/2009:22:59:29 +0000] "GET /vmw/vSphere/default/vmkernel.gz HTTP/1.0" 200 78929 "-" "gPXE/0.9.7"
|
||||
EOF
|
||||
|
||||
if test ! -d meta-sessions/.config/lnav; then
|
||||
echo "error: configuration not stored in .config/lnav?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -d meta-sessions/.lnav; then
|
||||
echo "error: configuration stored in .lnav?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
run_test ${lnav_test} -n \
|
||||
-c ":load-session" \
|
||||
-c ";UPDATE access_log SET log_mark = 1" \
|
||||
|
Loading…
Reference in New Issue
Block a user