Add a flag to specify the log level

This commit is contained in:
Victor Hurdugaci 2016-08-31 09:30:33 -07:00
parent 79cb3b0ed9
commit ac2f21514f
2 changed files with 24 additions and 4 deletions

View File

@ -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)

View File

@ -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<LogLevel>(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);