Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chill the logging out a bit #157

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading