Skip to content

Commit

Permalink
adding logging
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekkumams committed Nov 26, 2024
1 parent 450eb32 commit 0d1a9e0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
13 changes: 13 additions & 0 deletions src/Config/FileSystemRuntimeConfigLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,19 @@ public bool TryLoadConfig(
// mode in the new RuntimeConfig since we do not support hot-reload of the mode.
if (isDevMode is not null && config.Runtime is not null && config.Runtime.Host is not null)
{
// Log error when the mode is changed during hot-reload.
if (isDevMode.Value && HostMode.Production.Equals(config.Runtime.Host.Mode))
{
if (logger is null)
{
Console.WriteLine("Hot-reload doesn't support switching to Production mode. Please restart the service to switch the mode.");
}
else
{
logger.LogError("Hot-reload doesn't support switching to Production mode. Please restart the service to switch the mode.");
}
}

config.Runtime.Host.Mode = (bool)isDevMode ? HostMode.Development : HostMode.Production;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Service.Tests/dab-config.MsSql.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"$schema": "https://github.com/Azure/data-api-builder/releases/download/vmajor.minor.patch/dab.draft.schema.json",
"data-source": {
"database-type": "mssql",
"connection-string": "Server=tcp:127.0.0.1,1433;Persist Security Info=False;User ID=sa;Password=REPLACEME;MultipleActiveResultSets=False;Connection Timeout=5;",
"connection-string": "Server=tcp:127.0.0.1,1433;Persist Security Info=False;User ID=dabuser;Password=Adabpassword@1;TrustServerCertificate=True;MultipleActiveResultSets=False;Connection Timeout=5;",
"options": {
"set-session-context": true
}
},
"runtime": {
"rest": {
"enabled": true,
"path": "/api",
"path": "/apiz",
"request-body-strict": true
},
"graphql": {
Expand All @@ -33,7 +33,7 @@
"authentication": {
"provider": "StaticWebApps"
},
"mode": "development"
"mode": "production"
}
},
"entities": {
Expand Down

0 comments on commit 0d1a9e0

Please sign in to comment.