Skip to content

Commit

Permalink
Chill the logging out a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Shaw committed Aug 22, 2024
1 parent e28a451 commit 4fb27f5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
7 changes: 4 additions & 3 deletions src/CSnakes.Runtime/PackageManagement/PipInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ namespace CSnakes.Runtime.PackageManagement;
internal class PipInstaller(ILogger<PipInstaller> logger) : IPythonPackageInstaller
{
static readonly string pipBinaryName = $"pip{(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : "")}";
static readonly string requirementsFileName = "requirements.txt";

public Task InstallPackages(string home, string? virtualEnvironmentLocation)
{
// TODO:Allow overriding of the requirements file name.
string requirementsPath = Path.Combine(home, "requirements.txt");
string requirementsPath = Path.Combine(home, requirementsFileName);
if (File.Exists(requirementsPath))
{
logger.LogInformation("File {Requirements} was found.", requirementsPath);
Expand All @@ -30,7 +31,7 @@ private void InstallPackagesWithPip(string home, string? virtualEnvironmentLocat
{
WorkingDirectory = home,
FileName = pipBinaryName,
Arguments = "install -r requirements.txt"
Arguments = $"install -r {requirementsFileName} --disable-pip-version-check"
};

if (virtualEnvironmentLocation is not null)
Expand Down Expand Up @@ -58,7 +59,7 @@ private void InstallPackagesWithPip(string home, string? virtualEnvironmentLocat
{
if (!string.IsNullOrEmpty(e.Data))
{
logger.LogError("{Data}", e.Data);
logger.LogWarning("{Data}", e.Data);
}
};

Expand Down
8 changes: 4 additions & 4 deletions src/CSnakes.Runtime/PythonEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private PythonEnvironment(

if (extraPaths is { Length: > 0 })
{
logger.LogInformation("Adding extra paths to PYTHONPATH: {ExtraPaths}", extraPaths);
logger.LogDebug("Adding extra paths to PYTHONPATH: {ExtraPaths}", extraPaths);
api.PythonPath = api.PythonPath + sep + string.Join(sep, extraPaths);
}
api.Initialize();
Expand All @@ -112,7 +112,7 @@ private void EnsureVirtualEnvironment(PythonLocationMetadata pythonLocation, str
}
else
{
Logger.LogInformation("Virtual environment already exists at {VirtualEnvPath}", venvPath);
Logger.LogDebug("Virtual environment already exists at {VirtualEnvPath}", venvPath);
}

Process ExecutePythonCommand(PythonLocationMetadata pythonLocation, string? venvPath, string arguments)
Expand Down Expand Up @@ -155,8 +155,8 @@ private CPythonAPI SetupStandardLibrary(PythonLocationMetadata pythonLocationMet
string pythonDll = pythonLocationMetadata.LibPythonPath;
string pythonPath = pythonLocationMetadata.PythonPath;

Logger.LogInformation("Python DLL: {PythonDLL}", pythonDll);
Logger.LogInformation("Python path: {PythonPath}", pythonPath);
Logger.LogDebug("Python DLL: {PythonDLL}", pythonDll);
Logger.LogDebug("Python path: {PythonPath}", pythonPath);

var api = new CPythonAPI(pythonDll, pythonLocationMetadata.Version)
{
Expand Down
2 changes: 1 addition & 1 deletion src/CSnakes/Reflection/MethodReflection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public static MethodDefinition FromMethod(PythonFunctionDefinition function, str
MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
IdentifierName("logger"),
IdentifierName("LogInformation")))
IdentifierName("LogDebug")))
.WithArgumentList(
ArgumentList(
SeparatedList(
Expand Down

0 comments on commit 4fb27f5

Please sign in to comment.