Skip to content

Commit

Permalink
Merge pull request #157 from tonybaloney/calmer_logging
Browse files Browse the repository at this point in the history
Chill the logging out a bit
aaronpowell authored Aug 23, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 076865a + 4fb27f5 commit f8657e1
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
@@ -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);
@@ -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)
@@ -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);
}
};

8 changes: 4 additions & 4 deletions src/CSnakes.Runtime/PythonEnvironment.cs
Original file line number Diff line number Diff line change
@@ -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();
@@ -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)
@@ -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)
{
2 changes: 1 addition & 1 deletion src/CSnakes/Reflection/MethodReflection.cs
Original file line number Diff line number Diff line change
@@ -167,7 +167,7 @@ public static MethodDefinition FromMethod(PythonFunctionDefinition function, str
MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
IdentifierName("logger"),
IdentifierName("LogInformation")))
IdentifierName("LogDebug")))
.WithArgumentList(
ArgumentList(
SeparatedList(

0 comments on commit f8657e1

Please sign in to comment.