diff --git a/README.md b/README.md index 9fe921f7aa..11b1f68db4 100644 --- a/README.md +++ b/README.md @@ -25,13 +25,22 @@ Add `Microsoft.DotNet.Watcher.Tools` to the `tools` section of your `project.jso Add `watch` after `dotnet` in the command that you want to run: -| What you want to run | Dotnet watch command | +| What you want to run | Dotnet watch command | | ---------------------------------------------- | -------------------------------------------------------- | | dotnet run | dotnet **watch** run | | dotnet run --arg1 value1 | dotnet **watch** run --arg1 value | | dotnet run --framework net451 -- --arg1 value1 | dotnet **watch** run --framework net451 -- --arg1 value1 | | dotnet test | dotnet **watch** test | +### Advanced configuration options + +Configuration options can be passed to `dotnet watch` through environment variables. The available variables are: + +| Variable | Effect | +| ---------------------------------------------- | -------------------------------------------------------- | +| DOTNET_USE_POLLING_FILE_WATCHER | If set to "1" or "true", `dotnet watch` will use a polling file watcher instead of CoreFx's `FileSystemWatcher`. Used when watching files on network shares or Docker mounted volumes. | +| DOTNET_WATCH_LOG_LEVEL | Used to set the logging level for messages coming from `dotnet watch`. Accepted values `None`, `Trace`, `Debug`, `Information`, `Warning`, `Error`, `Critical`. Default: `Information`. | + AppVeyor: [![AppVeyor](https://ci.appveyor.com/api/projects/status/fxhto3omtehio3aj/branch/dev?svg=true)](https://ci.appveyor.com/project/aspnetci/dnx-watch/branch/dev) Travis: [![Travis](https://travis-ci.org/aspnet/dotnet-watch.svg?branch=dev)](https://travis-ci.org/aspnet/dotnet-watch) diff --git a/src/Microsoft.DotNet.Watcher.Tools/Program.cs b/src/Microsoft.DotNet.Watcher.Tools/Program.cs index d27c68e543..5b0cde0b71 100644 --- a/src/Microsoft.DotNet.Watcher.Tools/Program.cs +++ b/src/Microsoft.DotNet.Watcher.Tools/Program.cs @@ -19,7 +19,18 @@ namespace Microsoft.DotNet.Watcher.Tools { _loggerFactory = new LoggerFactory(); - var commandProvider = new CommandOutputProvider(); + var logVar = Environment.GetEnvironmentVariable("DOTNET_WATCH_LOG_LEVEL"); + + LogLevel logLevel; + if (string.IsNullOrEmpty(logVar) || !Enum.TryParse(logVar, out logLevel)) + { + logLevel = LogLevel.Information; + } + + var commandProvider = new CommandOutputProvider() + { + LogLevel = logLevel + }; _loggerFactory.AddProvider(commandProvider); } @@ -32,7 +43,7 @@ namespace Microsoft.DotNet.Watcher.Tools ctrlCTokenSource.Cancel(); ev.Cancel = false; }; - + return new Program().MainInternal(args, ctrlCTokenSource.Token); } } @@ -44,7 +55,7 @@ namespace Microsoft.DotNet.Watcher.Tools app.FullName = "Microsoft dotnet File Watcher"; app.HelpOption("-?|-h|--help"); - + app.OnExecute(() => { var projectToWatch = Path.Combine(Directory.GetCurrentDirectory(), ProjectModel.Project.FileName);