creating one package which includes sqltoolsservice and credential service (#444)

* creating one package which includes sqltoolsservice and credential service

* adding logDir arg to credentials program
This commit is contained in:
Leila Lali
2017-09-01 12:21:30 -07:00
committed by GitHub
parent 44d3e4b17e
commit 22ccac98ae
5 changed files with 55 additions and 12 deletions

View File

@@ -3,6 +3,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.IO;
using Microsoft.SqlTools.Credentials.Utility;
using Microsoft.SqlTools.ServiceLayer.SqlContext;
using Microsoft.SqlTools.Utility;
@@ -28,9 +29,15 @@ namespace Microsoft.SqlTools.Credentials
return;
}
string logFilePath = "credentials";
if (!string.IsNullOrWhiteSpace(commandOptions.LoggingDirectory))
{
logFilePath = Path.Combine(commandOptions.LoggingDirectory, logFilePath);
}
// turn on Verbose logging during early development
// we need to switch to Normal when preparing for public preview
Logger.Initialize(minimumLogLevel: LogLevel.Verbose, isEnabled: commandOptions.EnableLogging);
Logger.Initialize(logFilePath, minimumLogLevel: LogLevel.Verbose, isEnabled: commandOptions.EnableLogging);
Logger.Write(LogLevel.Normal, "Starting SqlTools Credentials Provider");
// set up the host details and profile paths

View File

@@ -4,6 +4,7 @@
//
using System;
using System.IO;
namespace Microsoft.SqlTools.Credentials.Utility
{
@@ -26,11 +27,19 @@ namespace Microsoft.SqlTools.Credentials.Utility
string arg = args[i];
if (arg.StartsWith("--") || arg.StartsWith("-"))
{
if (arg.StartsWith("--"))
{
// Extracting arguments and properties
arg = arg.Substring(1).ToLowerInvariant();
}
switch (arg)
{
case "-enable-logging":
EnableLogging = true;
break;
case "-log-dir":
SetLoggingDirectory(args[++i]);
break;
case "h":
case "-help":
ShouldExit = true;
@@ -64,11 +73,26 @@ namespace Microsoft.SqlTools.Credentials.Utility
/// </summary>
public bool EnableLogging { get; private set; }
/// <summary>
/// Gets the directory where log files are output.
/// </summary>
public string LoggingDirectory { get; private set; }
/// <summary>
/// Whether the program should exit immediately. Set to true when the usage is printed.
/// </summary>
public bool ShouldExit { get; private set; }
private void SetLoggingDirectory(string loggingDirectory)
{
if (string.IsNullOrWhiteSpace(loggingDirectory))
{
return;
}
this.LoggingDirectory = Path.GetFullPath(loggingDirectory);
}
/// <summary>
/// Get the usage string describing command-line arguments for the program
/// </summary>