Skip to content
This repository has been archived by the owner on Jul 28, 2018. It is now read-only.

Consider namespacing logs #32

Open
michalmuskala opened this issue Apr 30, 2017 · 7 comments
Open

Consider namespacing logs #32

michalmuskala opened this issue Apr 30, 2017 · 7 comments

Comments

@michalmuskala
Copy link

michalmuskala commented Apr 30, 2017

Currently, all logs are stored together. That's completely fine, but it becomes problematic when using multiple different repls - erl, iex and lfe since all history is stored together. So now I can "scroll up" elixir commands in lfe or erlang - this is not desirable.

Both lfe and iex achieve the custom repl by passing the -user argument to erl executable. This argument can be obtained using init:get_argument(user) - I'm not sure if there exists a more internal API exposing an already parsed value.

I propose to store logs in ~/.erlang-hostory/<user>/ directory, where <user> is the value of the init argument. As far as I understand the code, this will allow separating the Erlang, Elixir and LFE shell history rather easily.

@ferd
Copy link
Owner

ferd commented Apr 30, 2017

The PR I have in OTP erlang/otp#1420 lets you configure the path for logs through a kernel env var (the paths are also moved to ~/.cache/ by default). Would this mechanism make sense for you here?

@michalmuskala
Copy link
Author

Yes, I think it would be possible for iex to automatically configure this, though it might be hard to do this reliably in a cross-platform way. On the erlang side the use of filename:basedir/2 makes it quite easy, but both iex and lfe are simple bash/batch scripts, so they don't have access to this.

Maybe a way to pass a path relative to the default one would be a solution?

@ferd
Copy link
Owner

ferd commented Apr 30, 2017

I was more thinking of having their bash script add an item like -kernel shell_history_path ~/.cache/iex-history/ so they segment themselves on their own.

@michalmuskala
Copy link
Author

It's not as simple - filename:basedir uses ~/.cache only on Linux. On macOS it will use ~/Library/Caches, etc - on each platform according to the platform's conventions.

@ferd
Copy link
Owner

ferd commented Apr 30, 2017

yeah but they can just put it into ~/.erlang-history like this library currently does, but with their own prefix. The path is configurable, I don't really have to worry what it is configured to if you don't want the default?

@josevalim
Copy link

It is worth pointing out that you can have the same shell running multiple languages. Just press Ctrl+G and start a new session in whatever language you like. So I would say this needs to be configurable per session, much like the expand_fun option is configured per session directly via io:setopts. However I am not sure if this is a possibility.

@ferd
Copy link
Owner

ferd commented Apr 30, 2017

There is no way to do such thing since there is no context to pass around for it nor is there any way to identify a session.

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

No branches or pull requests

3 participants