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

By default, log only to stderr, and not to disk. #284

Merged
merged 1 commit into from
Dec 18, 2018

Conversation

eminence
Copy link
Contributor

This fixes a common problem when running under VS Code, the user doesn't have permissions to create a log directory in the CWD.

The old behavior can be re-enabled by setting RA_INTERNAL_MODE=1

Fixes #282

This fixes a common problem when running under VS Code, the user
doesn't have permissions to create a `log` directory in the CWD.

The old behavior can be re-enabled by setting RA_INTERNAL_MODE=1
@DJMcNab
Copy link
Contributor

DJMcNab commented Dec 17, 2018

Nit: can you not do the match statement as

if std::env::var("RA_INTERNAL_MODE) == Ok(1){
   ... 
} 

? I might be wrong, and can't check atm

@eminence
Copy link
Contributor Author

You can't do that because Ok("1") is a Result<&str>, but std::env::var returns a Result<String>.

You could of course do Ok("1".to_owned()), but I thought I'd skip the allocation with a match guard instead.

@DJMcNab
Copy link
Contributor

DJMcNab commented Dec 18, 2018

Ah, well we don't really care about allocations in ra_lsp_server.

Anyway, here's the tracking issue for the api that would allow this easily. rust-lang/rust#50264 .

@matklad
Copy link
Member

matklad commented Dec 18, 2018

bors r+

Thanks!

bors bot added a commit that referenced this pull request Dec 18, 2018
284: By default, log only to stderr, and not to disk. r=matklad a=eminence

This fixes a common problem when running under VS Code, the user doesn't have permissions to create a `log` directory in the CWD.

The old behavior can be re-enabled by setting `RA_INTERNAL_MODE=1`

Fixes #282

Co-authored-by: Andrew Chin <achin@eminence32.net>
@bors
Copy link
Contributor

bors bot commented Dec 18, 2018

Build succeeded

@bors bors bot merged commit 8b1e667 into rust-lang:master Dec 18, 2018
@DJMcNab
Copy link
Contributor

DJMcNab commented Dec 18, 2018

Actually, I think we can also do

let var = std::env::var("RA_INTERNAL_MODE“);
if var.map(Deref::deref) ==Ok("1"){
   ... 
}

@eminence eminence deleted the log_control branch December 19, 2018 04:18
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

Successfully merging this pull request may close these issues.

Don't write logs to the dir at cwd by default
3 participants