public ReportDirectoryHandler(string rootFolder, string fileName, DateTime dateTime, ITraceLogger traceLogger)
            : this()
        {
            _directoryPath = new DirectoryInfo(rootFolder);
            if (!_directoryPath.Exists)
            {
                _directoryPath.Create();
            }

            var steamFolder = "steams";

            _steamPath = new DirectoryInfo(Path.Combine(_directoryPath.FullName, steamFolder));
            if (!_steamPath.Exists)
            {
                _steamPath = _directoryPath.CreateSubdirectory(steamFolder, _directoryPath.GetAccessControl());
            }

            var logFolder = "logs";

            _logPath = new DirectoryInfo(Path.Combine(_directoryPath.FullName, logFolder));
            if (!_logPath.Exists)
            {
                _logPath = _directoryPath.CreateSubdirectory(logFolder, _directoryPath.GetAccessControl());
            }

            TraceLogger = traceLogger;

            _fileName = fileName;
            _dateTime = dateTime;
        }
コード例 #2
0
        public async Task Invoke(HttpContext context)
        {
            string message;
            string userTraceId = context.Request?.Headers["userTraceId"];

            if (string.IsNullOrEmpty(userTraceId))
            {
                userTraceId = Guid.NewGuid().ToString();
                message     = $"Received a request and created a new TraceId";
            }
            else
            {
                message = $"Received a request with TraceId";
            }

            context.Items["userTraceId"] = userTraceId;

            using (var scope = _services.CreateScope())
            {
                ITraceLogger logger = scope.ServiceProvider.GetRequiredService <ITraceLogger>();
                logger.Log(message);
            }

            await _next(context);
        }
コード例 #3
0
        /// <summary>
        /// Returns the parent item ID
        /// </summary>
        /// <param name="cContext"></param>
        /// <param name="ItemName"></param>
        /// <param name="logger">diagnostics logger</param>
        /// <returns></returns>
        static int GetUserID(ClientContext cContext, dynamic ItemName, ITraceLogger logger)
        {
            int nReturn = -1;
            NativeFieldUserValue userValue = null;

            try
            {
                string itemJsonString = ItemName.ToString();
                Newtonsoft.Json.Linq.JObject jobject = Newtonsoft.Json.Linq.JObject.Parse(itemJsonString);
                userValue = jobject.ToObject <NativeFieldUserValue>();


                logger.LogInformation("Start GetUserID {0}", userValue.Email);
                Web wWeb  = cContext.Web;
                var iUser = cContext.Web.EnsureUser(userValue.Email);
                cContext.Load(iUser);
                cContext.ExecuteQueryRetry();
                if (iUser != null)
                {
                    return(iUser.Id);
                }
            }
            catch (Exception ex)
            {
                logger.LogError(ex, "Failed to find {0} in web {1}", ItemName, ex.Message);
            }

            return(nReturn);
        }
コード例 #4
0
ファイル: SOFA.cs プロジェクト: alvahdean/ASCOM.NETStandard
 protected virtual void Dispose(bool disposing)
 {
     if (!disposedValue)
     {
         if (disposing)
         {
             if (Utl != null)
             {
                 Utl.Dispose();
                 Utl = (Util)null;
             }
             if (TL != null)
             {
                 TL.Enabled = false;
                 TL.Dispose();
                 TL = null;
             }
         }
         try
         {
             ASCOM.Astrometry.SOFA.SOFA.FreeLibrary(SofaDllHandle);
         }
         catch (Exception ex)
         {
             //ProjectData.SetProjectError(ex);
             //ProjectData.ClearProjectError();
         }
     }
     disposedValue = true;
 }
コード例 #5
0
        public void TraceLoggerPropertyTest()
        {
            SharePointLogger logger = new SharePointLogger();

            try
            {
                ITraceLogger iTLogger = logger.TraceLogger;
                TraceLogger  tlogger  = new TraceLogger();
                if (!iTLogger.GetType().IsInterface)
                {
                    if (iTLogger.GetType().ToString() == tlogger.GetType().ToString())
                    {
                        Assert.IsTrue(true);
                    }
                    else
                    {
                        Assert.Fail("There is a type mismatch");
                    }
                }
                else
                {
                    Assert.Fail("Interface was returned");
                }
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
コード例 #6
0
 public void SetLogger(ITraceLogger logger)
 {
     if (logger != null)
     {
         this.logger = logger;
     }
 }
コード例 #7
0
ファイル: SOFA.cs プロジェクト: alvahdean/ASCOM.NETStandard
        public SOFA()
        {
            disposedValue = false;
            StringBuilder lpszPath = new StringBuilder(260);

            TL         = new TraceLogger("", "SOFA");
            TL.Enabled = RegistryCommonCode.GetBool("Trace NOVAS", false);
            Utl        = new Util();
            string lpFileName;

            if (Is64Bit())
            {
                ASCOM.Astrometry.SOFA.SOFA.SHGetSpecialFolderPath(IntPtr.Zero, lpszPath, 44, false);
                lpFileName = lpszPath.ToString() + "\\ASCOM\\Astrometry\\SOFA11-64.dll";
            }
            else
            {
                lpFileName = Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles) + "\\ASCOM\\Astrometry\\SOFA11.dll";
            }
            TL.LogMessage("New", "Loading SOFA library DLL: " + lpFileName);
            SofaDllHandle = ASCOM.Astrometry.SOFA.SOFA.LoadLibrary(lpFileName);
            int lastWin32Error = Marshal.GetLastWin32Error();

            if (SofaDllHandle != IntPtr.Zero)
            {
                TL.LogMessage("New", "Loaded SOFA library OK");
                TL.LogMessage("New", "SOFA Initialised OK");
            }
            else
            {
                TL.LogMessage("New", "Error loading SOFA library: " + lastWin32Error.ToString("X8"));
                throw new HelperException("Error code returned from LoadLibrary when loading SOFA library: " + lastWin32Error.ToString("X8"));
            }
        }
コード例 #8
0
        public TracingDecoratorSimulator(ITraceLogger logger, ISimulator sim, string name)
        {
            this.logger = logger;
            this.sim    = sim;

            simulatorName = name;
        }
コード例 #9
0
 protected virtual void Dispose(bool disposing)
 {
     if (!disposedValue)
     {
         if (disposing)
         {
             if (TL != null)
             {
                 TL.Enabled = false;
                 TL.Dispose();
                 TL = null;
             }
             if (Utl != null)
             {
                 Utl.Dispose();
                 Utl = (Util)null;
             }
         }
         if (Nov31 != null)
         {
             Nov31.Dispose();
             Nov31 = (NOVAS31)null;
         }
     }
     disposedValue = true;
 }
コード例 #10
0
 public PipelineTestRunPublisher(IClientFactory clientFactory, IPipelineConfig pipelineConfig, ITraceLogger logger, ITelemetryDataCollector telemetry)
 {
     _logger         = logger;
     _telemetry      = telemetry;
     _pipelineConfig = pipelineConfig;
     _httpClient     = clientFactory.GetClient <TestResultsHttpClient>();
 }
コード例 #11
0
 internal MemberFactory(string progId, TraceLogger ascomDriverTraceLogger)
 {
     this.TL = ascomDriverTraceLogger;
     this.TL.LogMessage("ProgID", progId);
     this._strProgId    = progId;
     this.GetInterfaces = new List <Type>();
     this.GetObjType    = Type.GetTypeFromProgID(progId);
     if (this.GetObjType == null)
     {
         throw new HelperException("Check Driver: cannot create object type of progID: " + this._strProgId);
     }
     this.IsComObject = this.GetObjType.IsCOMObject;
     this.TL.LogMessage("IsComObject", this.GetObjType.IsCOMObject.ToString());
     this.GetLateBoundObject = Activator.CreateInstance(this.GetObjType);
     try
     {
         foreach (Type type in this.GetObjType.GetInterfaces())
         {
             this.GetInterfaces.Add(type);
             this.TL.LogMessage("GetInterfaces", "Found interface: " + type.AssemblyQualifiedName);
         }
     }
     catch (Exception ex)
     {
         this.TL.LogMessageCrLf("GetInterfaces", "Exception: " + ex.ToString());
     }
     if (this.GetLateBoundObject == null)
     {
         this.TL.LogMessage("Exception", "GetLateBoudObject is null, throwing HelperException");
         throw new HelperException("Check Driver: cannot create driver instance of progID: " + this._strProgId);
     }
 }
コード例 #12
0
 public DocumentExecuter(IDocumentBuilder documentBuilder, IDocumentValidator documentValidator, IComplexityAnalyzer complexityAnalyzer, ITraceLogger traceLogger)
 {
     _documentBuilder    = documentBuilder ?? throw new ArgumentNullException(nameof(documentBuilder));
     _documentValidator  = documentValidator ?? throw new ArgumentNullException(nameof(documentValidator));
     _complexityAnalyzer = complexityAnalyzer ?? throw new ArgumentNullException(nameof(complexityAnalyzer));
     _traceLogger        = traceLogger ?? throw new ArgumentNullException(nameof(traceLogger));
 }
コード例 #13
0
 public AzureADTokenCache(IAzureADConfig aadConfig, ITraceLogger iLogger)
 {
     _aadConfig      = aadConfig;
     _authContext    = new AuthenticationContext(string.Format(AzureADConstants.AuthorityTenantFormat, _aadConfig.TenantDomain));
     _appCredentials = new ClientCredential(_aadConfig.ClientId, _aadConfig.ClientSecret);
     _iLogger        = iLogger;
 }
コード例 #14
0
        public AzureADv2TokenCache(IAppSettings aadConfig, ITraceLogger iLogger, bool useInteractiveLogin)
        {
            if (aadConfig == null)
            {
                throw new ArgumentNullException(nameof(aadConfig));
            }

            _aadConfig = aadConfig;
            _iLogger   = iLogger;

            IClientApplicationBase clientApplication;

            if (useInteractiveLogin)
            {
                var publicClientApplicationOptions = new PublicClientApplicationOptions()
                {
                    AadAuthorityAudience = _aadConfig.AadAuthorityAudience,
                    AzureCloudInstance   = _aadConfig.AzureCloudInstance,
                    ClientId             = _aadConfig.ClientId,
                    RedirectUri          = "urn:ietf:wg:oauth:2.0:oob",
                    TenantId             = _aadConfig.TenantId
                };
                clientApplication = PublicClientApplicationBuilder.CreateWithApplicationOptions(publicClientApplicationOptions)
                                    .Build();
            }
            else
            {
                clientApplication = ConfidentialClientApplicationBuilder.Create(_aadConfig.ClientId)
                                    .WithClientSecret(_aadConfig.ClientSecret)
                                    .WithAuthority(new Uri(_aadConfig.Authority))
                                    .Build();
            }

            _authContext = new GraphMsalAuthenticationProvider(clientApplication, aadConfig.MSALScopes);
        }
コード例 #15
0
 /// <summary>
 /// Creates a timer with threshold. A perf message is logged only if
 /// the time elapsed is more than the threshold.
 /// </summary>
 public SimpleTimer(string timerName, ITraceLogger logger, TelemetryDataWrapper telemetryWrapper, TimeSpan threshold)
 {
     _name             = timerName;
     _logger           = logger;
     _threshold        = threshold;
     _telemetryWrapper = telemetryWrapper;
     _timer            = Stopwatch.StartNew();
 }
コード例 #16
0
        /// <summary>
        /// Default constructor accepting only test run manager instance, rest of the requirements assume default values
        /// </summary>
        public PythonTestResultParser(ITestRunManager testRunManager, ITraceLogger logger, ITelemetryDataCollector telemetry) : base(testRunManager, logger, telemetry)
        {
            base.logger.Info("PythonTestResultParser : Starting python test result parser.");
            base.telemetry.AddToCumulativeTelemetry(PythonTelemetryConstants.EventArea, PythonTelemetryConstants.Initialize, true);

            this.state          = ParserState.ExpectingTestResults;
            this.currentTestRun = new TestRun($"{Name}/{Version}", this.currentTestRunId);
        }
コード例 #17
0
ファイル: MockupCluster.cs プロジェクト: zmyer/service-fabric
        private void SetStateMachine(ITraceLogger traceLogger)
        {
            var stateActivator = new MockupUpgradeStateActivator();
            var factory        = new ClusterUpgradeStateFactory(this, stateActivator, traceLogger);

            this.stateMachine   = new ClusterResourceStateMachine(this, factory, traceLogger);
            this.UpgradeFactory = factory;
        }
コード例 #18
0
 /// <summary>
 /// Constructor for a node parser state
 /// </summary>
 /// <param name="parserResetAndAttempPublish">Delegate sent by the parser to reset the parser and attempt publication of test results</param>
 /// <param name="logger"></param>
 /// <param name="telemetryDataCollector"></param>
 protected NodeParserStateBase(ParserResetAndAttemptPublish parserResetAndAttempPublish, ITraceLogger logger, ITelemetryDataCollector telemetryDataCollector, string parserName)
 {
     Logger     = logger;
     ParserName = parserName;
     StateName  = GetType().Name;
     Telemetry  = telemetryDataCollector;
     AttemptPublishAndResetParser = parserResetAndAttempPublish;
 }
コード例 #19
0
 public StandAloneAutoScaleClusterUpgradeState(
     IUserConfig targetCsmConfig,
     IAdminConfig targetWrpConfig,
     ClusterNodeConfig targetNodeConfig,
     ICluster clusterResource,
     ITraceLogger traceLogger)
     : base(targetCsmConfig, targetWrpConfig, targetNodeConfig, clusterResource, traceLogger)
 {
 }
コード例 #20
0
 public GatekeepingClusterUpgradeState CreateGatekeepingClusterUpgradeState(
     IUserConfig targetCsmConfig,
     IAdminConfig targetWrpConfig,
     ClusterNodeConfig targetNodeConfig,
     ICluster clusterResource,
     ITraceLogger traceLogger)
 {
     return(new MockupGatekeepingClusterUpgradeState(targetCsmConfig, targetWrpConfig, targetNodeConfig, clusterResource, traceLogger));
 }
コード例 #21
0
 public SeedNodeSelector(TimeSpan timeout, ITraceLogger logger)
 {
     this.timeout          = timeout;
     this.timeoutHelper    = new TimeoutHelper(timeout);
     this.lastNodeCount    = 0;
     this.faultDomainMap   = new Dictionary <string, int>();
     this.upgradeDomainMap = new Dictionary <string, int>();
     this.traceLogger      = logger;
 }
コード例 #22
0
        /// <summary>
        /// Initialize the Graph API Executor with Azure AD Config settings and the Diagnostic Logger
        /// </summary>
        /// <param name="config"></param>
        /// <param name="logger"></param>
        public ReportingStream(AzureEnvironment environment, IAzureADConfig config, ITraceLogger logger)
        {
            var authenticationEndpoint = environment.GetAzureADLoginEndPoint();
            var endpoint = string.Format(AzureADConstants.AuthorityTenantFormat, authenticationEndpoint, config.TenantDomain);

            this.ADConfig   = config;
            this.Logger     = logger;
            this.OAuthCache = new AzureADTokenCache(endpoint, config, logger);
        }
コード例 #23
0
 public TestFilePublisher(VssConnection vssConnection, PipelineConfig pipelineConfig, TraceListener traceListener,
                          ITraceLogger logger, ITelemetryDataCollector telemetry)
 {
     _traceListener  = traceListener;
     _vssConnection  = vssConnection;
     _pipelineConfig = pipelineConfig;
     _logger         = logger;
     _telemetry      = telemetry;
 }
コード例 #24
0
 public TestFilePublisher(VssConnection vssConnection, PipelineConfig pipelineConfig, TraceListener traceListener,
                          ITraceLogger logger, ITelemetryDataCollector telemetry, ITestFileFinder testFileFinder,
                          ITestResultParser testResultParser, ITestRunPublisher testRunPublisher)
     : this(vssConnection, pipelineConfig, traceListener, logger, telemetry)
 {
     _testFileFinder   = testFileFinder;
     _testResultParser = testResultParser;
     _testRunPublisher = testRunPublisher;
 }
コード例 #25
0
 public BaselineClusterUpgradeStateBase CreateBaselineUpgradeState(
     IUserConfig csmConfig,
     IAdminConfig wrpConfig,
     ClusterNodeConfig nodeConfig,
     ICluster clusterResource,
     ITraceLogger traceLogger)
 {
     return(new MockupBaselineUpgradeState(csmConfig, wrpConfig, nodeConfig, clusterResource, traceLogger));
 }
コード例 #26
0
 public ClusterUpgradeStateFactory(
     ICluster clusterResource,
     IUpgradeStateActivator upgradeStateActivator,
     ITraceLogger traceLogger)
 {
     this.clusterResource       = clusterResource;
     this.upgradeStateActivator = upgradeStateActivator;
     this.traceLogger           = traceLogger;
 }
コード例 #27
0
 public MockupSimpleClusterUpgradeState(
     IUserConfig targetCsmConfig,
     IAdminConfig targetWrpConfig,
     ClusterNodeConfig targetNodeConfig,
     ICluster clusterResource,
     ITraceLogger traceLogger)
     : base(targetCsmConfig, targetWrpConfig, targetNodeConfig, clusterResource, traceLogger)
 {
 }
コード例 #28
0
 public static IEnumerable <string> TryFindCertificate(
     StoreName storeName,
     IEnumerable <string> findValues,
     X509FindType findType,
     out IEnumerable <X509Certificate2> foundCertificates,
     ITraceLogger traceLogger = null)
 {
     return(X509CertificateUtility.TryFindCertificate(string.Empty, storeName, findValues, findType, out foundCertificates, traceLogger));
 }
コード例 #29
0
 protected GatekeepingClusterUpgradeState(
     IUserConfig targetCsmConfig,
     IAdminConfig targetWrpConfig,
     ClusterNodeConfig targetNodeConfig,
     ICluster clusterResource,
     ITraceLogger traceLogger)
     : base(targetCsmConfig, targetWrpConfig, targetNodeConfig, clusterResource, traceLogger)
 {
 }
コード例 #30
0
        /// <summary>
        /// Default constructor accepting only test run manager instance, rest of the requirements assume default values
        /// </summary>
        public PythonTestResultParser(ITestRunManager testRunManager, ITraceLogger logger, ITelemetryDataCollector telemetry)
            : base(testRunManager, logger, telemetry)
        {
            Logger.Info("PythonTestResultParser : Starting python test result parser.");
            Telemetry.AddOrUpdate(PythonTelemetryConstants.Initialize, true, PythonTelemetryConstants.EventArea);

            _state          = ParserState.ExpectingTestResults;
            _currentTestRun = new TestRun($"{Name}/{Version}", "Python", _currentTestRunId);
        }
コード例 #31
0
		public override void RuntimeInitialize(MethodBase method)
		{
			this.methodName = 
				method.DeclaringType==null
				? method.Name 
				: method.DeclaringType.FullName + "." + method.Name;
			this.enteringMessage = "Entering " + methodName;
			this.exitingMessage = "Exiting " + methodName;
		    if (logger == null)
		    {
		        logger = Bootstrap.GetLogger();
		    }
		}
コード例 #32
0
ファイル: Bootstrap.cs プロジェクト: smartpcr/Instrumentation
 public static ITraceLogger GetLogger()
 {
     if (logger == null)
     {
         if (ConfigurationManager.AppSettings.Get("TraceLoggerType") == "Mock")
         {
             logger = new ConsoleTraceLogger();
         }
         else
         {
             logger=new EtwTraceEventSource();
         }
     }
     return logger;
 }
コード例 #33
0
ファイル: TraceLogger.cs プロジェクト: ValdimarThor/Cocktail
 static TraceLogger()
 {
     var defaultLoggerProvider = new DefaultLoggerProvider();
     DefaultTraceLogger = defaultLoggerProvider.GetLogger();
 }
コード例 #34
0
ファイル: N2Logger.cs プロジェクト: grbbod/drconnect-jungo
        public N2Logger(ITraceLogger log) 
		{
			_log = log;
		}
コード例 #35
0
 public JungoLoggingHttpModule(ITraceLogger traceLogger)
 {
     _traceLogger = traceLogger;
 }