Commit 643970b
authored
Fix CLI overrides LogLevel value from config file (#3426)
## Why make this change?
- Closes issue #3258
Whenever we use the `dab start` command the CLI overrides the minimum
LogLevel from the configuration file. This is acceptable only if we use
the `--LogLevel` flag. If we do not use that flag, the LogLevel for each
namespace should be decided by the configuration file.
## What is this change?
This change moves the `args.Add` methods inside the `ConfigGenerator.cs`
so that they are only applied when we use the `--LogLevel` flag. Having
these arguments causes DAB to not allow any changes to the LogLevel in
the loggers, since those arguments were always being added, DAB always
assumed the CLI was overriding the LogLevel when it was not expected as
it would use the `--LogLevel` flag to determine if it was an
`IsLogLevelOverridenByCli` scenario.
## How was this tested?
- [ ] Integration Tests
- [x] Unit Tests
- [x] Manual Tests
Tested with different configurations of the namespaces in the
`log-level` property inside the config file.
Note: ALL these manual tests were tested by running the CLI as well as
running DAB through Visual Studio.
Config file includes:
```
"log-level": {
"Azure.DataApiBuilder.Core.Services.ISqlMetadataProvider": "Information",
"Azure.DataApiBuilder.Core": "Debug",
"Azure.DataApiBuilder.Config.FileSystemRuntimeConfigLoader": "Error",
"default": "Warning"
}
```
Expected results:
- All the logs from
`Azure.DataApiBuilder.Core.Services.ISqlMetadataProvider` will provide
logs from log level information and above.
- All logs from `Azure.DataApiBuilder.Core` and its sub-namespaces that
are not from `ISqlMetadataProvider` will provide logs from log level
debug and above.
- All logs from
`Azure.DataApiBuilder.Config.FileSystemRuntimeConfigLoader` will provide
logs from log level error and above.
- Everything else will provide logs from log level warning and above,
including CLI.
Config file includes:
```
"log-level": {
"Azure.DataApiBuilder.Core": "Information",
"Azure.DataApiBuilder.Config": "Debug",
}
```
Expected results:
- All logs from `Azure.DataApiBuilder.Core` and its sub-namespaces will
provide logs from log level information and above.
- All logs from `Azure.DataApiBuilder.Config` and its sub-namespaces
will provide logs from log level debug and above.
- Everything else will provide logs from log level debug and above with
`host.mode = development`, including CLI.
Config file includes:
```
"log-level": {
"Default: none
}
```
Expected results:
- No logs will be printed, including CLI.
## Sample Request(s)
dab start --LogLevel information
dab start (With config file default value debug)1 parent 3d0ee44 commit 643970b
2 files changed
Lines changed: 80 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
857 | 858 | | |
858 | 859 | | |
859 | 860 | | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
860 | 938 | | |
861 | 939 | | |
862 | 940 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2732 | 2732 | | |
2733 | 2733 | | |
2734 | 2734 | | |
| 2735 | + | |
| 2736 | + | |
2735 | 2737 | | |
2736 | 2738 | | |
2737 | | - | |
2738 | | - | |
2739 | | - | |
2740 | | - | |
2741 | | - | |
2742 | | - | |
2743 | | - | |
2744 | | - | |
2745 | | - | |
2746 | | - | |
2747 | 2739 | | |
2748 | 2740 | | |
2749 | 2741 | | |
| |||
0 commit comments