Add a flag to specify the log level
This commit is contained in:
parent
79cb3b0ed9
commit
ac2f21514f
11
README.md
11
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:
|
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 | dotnet **watch** run |
|
||||||
| dotnet run --arg1 value1 | dotnet **watch** run --arg1 value |
|
| dotnet run --arg1 value1 | dotnet **watch** run --arg1 value |
|
||||||
| dotnet run --framework net451 -- --arg1 value1 | dotnet **watch** run --framework net451 -- --arg1 value1 |
|
| dotnet run --framework net451 -- --arg1 value1 | dotnet **watch** run --framework net451 -- --arg1 value1 |
|
||||||
| dotnet test | dotnet **watch** test |
|
| 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: [](https://ci.appveyor.com/project/aspnetci/dnx-watch/branch/dev)
|
AppVeyor: [](https://ci.appveyor.com/project/aspnetci/dnx-watch/branch/dev)
|
||||||
|
|
||||||
Travis: [](https://travis-ci.org/aspnet/dotnet-watch)
|
Travis: [](https://travis-ci.org/aspnet/dotnet-watch)
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,18 @@ namespace Microsoft.DotNet.Watcher.Tools
|
||||||
{
|
{
|
||||||
_loggerFactory = new LoggerFactory();
|
_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);
|
_loggerFactory.AddProvider(commandProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -32,7 +43,7 @@ namespace Microsoft.DotNet.Watcher.Tools
|
||||||
ctrlCTokenSource.Cancel();
|
ctrlCTokenSource.Cancel();
|
||||||
ev.Cancel = false;
|
ev.Cancel = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
return new Program().MainInternal(args, ctrlCTokenSource.Token);
|
return new Program().MainInternal(args, ctrlCTokenSource.Token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -44,7 +55,7 @@ namespace Microsoft.DotNet.Watcher.Tools
|
||||||
app.FullName = "Microsoft dotnet File Watcher";
|
app.FullName = "Microsoft dotnet File Watcher";
|
||||||
|
|
||||||
app.HelpOption("-?|-h|--help");
|
app.HelpOption("-?|-h|--help");
|
||||||
|
|
||||||
app.OnExecute(() =>
|
app.OnExecute(() =>
|
||||||
{
|
{
|
||||||
var projectToWatch = Path.Combine(Directory.GetCurrentDirectory(), ProjectModel.Project.FileName);
|
var projectToWatch = Path.Combine(Directory.GetCurrentDirectory(), ProjectModel.Project.FileName);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue