// Constructors internal ParseClient(EnvironmentSetting environment, IMonitorLogger logger) : base(CreateRestClient(environment)) { _environmentSetting = environment; this.ApplicationId = GetApplicationId(environment); Debug.Assert(!String.IsNullOrWhiteSpace(ApplicationId), "Parse Application ID is invalid. Retrieving books from Parse probably won't work. Consider checking your environment variables."); Logger = logger; }
public Harvester(HarvesterCommonOptions options) { // Note: If the same machine runs multiple BloomHarvester processes, then you need to add a suffix to this. this.Identifier = Environment.MachineName; if (options.SuppressLogs) { _logger = new ConsoleLogger(); } else { EnvironmentSetting azureMonitorEnvironment = EnvironmentUtils.GetEnvOrFallback(options.LogEnvironment, options.Environment); _logger = new AzureMonitorLogger(azureMonitorEnvironment, this.Identifier); } EnvironmentSetting parseDBEnvironment = EnvironmentUtils.GetEnvOrFallback(options.ParseDBEnvironment, options.Environment); _parseClient = new ParseClient(parseDBEnvironment); _parseClient.Logger = _logger; string downloadBucketName; string uploadBucketName; switch (parseDBEnvironment) { case EnvironmentSetting.Prod: downloadBucketName = BloomS3Client.ProductionBucketName; uploadBucketName = HarvesterS3Client.HarvesterProductionBucketName; break; case EnvironmentSetting.Test: downloadBucketName = BloomS3Client.UnitTestBucketName; uploadBucketName = HarvesterS3Client.HarvesterUnitTestBucketName; break; case EnvironmentSetting.Dev: case EnvironmentSetting.Local: default: downloadBucketName = BloomS3Client.SandboxBucketName; uploadBucketName = HarvesterS3Client.HarvesterSandboxBucketName; break; } _transfer = new BookTransfer(_parseClient, bloomS3Client: new HarvesterS3Client(downloadBucketName), htmlThumbnailer: null, bookDownloadStartingEvent: new BookDownloadStartingEvent()); _s3UploadClient = new HarvesterS3Client(uploadBucketName); }
public Harvester(HarvesterCommonOptions options) { this.Identifier = Environment.MachineName; if (options.SuppressLogs) { _logger = new ConsoleLogger(); } else { EnvironmentSetting azureMonitorEnvironment = EnvironmentUtils.GetEnvOrFallback(options.LogEnvironment, options.Environment); _logger = new AzureMonitorLogger(azureMonitorEnvironment, this.Identifier); } EnvironmentSetting parseDBEnvironment = EnvironmentUtils.GetEnvOrFallback(options.ParseDBEnvironment, options.Environment); _parseClient = new ParseClient(parseDBEnvironment); _parseClient.Logger = _logger; }
public DiskSpaceManager(IDriveInfo driveInfo, IMonitorLogger logger, IIssueReporter issueReporter) { this.DriveInfo = driveInfo; this.Logger = logger; this.IssueReporter = issueReporter; }
public Book(BookModel bookModel, IMonitorLogger logger, IFileIO fileIO) { Model = bookModel; _logger = logger; _fileIO = fileIO; }
public FontChecker(int getFontsTimeoutSecs, IBloomCliInvoker bloomCli, IMonitorLogger logger) { _kGetFontsTimeoutSecs = getFontsTimeoutSecs; _bloomCli = bloomCli; _logger = logger ?? NullLogger.Instance; }
internal BloomCliInvoker(IMonitorLogger logger) { this.Logger = logger; }
public void SetupBeforeEachTest() { _fakeDriveInfo = Substitute.For <IDriveInfo>(); _issueReporter = Substitute.For <IIssueReporter>(); _logger = Substitute.For <IMonitorLogger>(); }
public AzureMonitorLogger(EnvironmentSetting environment, string harvesterId) { _issueReporter = YouTrackIssueConnector.GetInstance(environment); // Get the Instrumentation Key for Azure from an environment variable. string environmentVarName = "BloomHarvesterAzureAppInsightsKeyDev"; if (environment == EnvironmentSetting.Test) { environmentVarName = "BloomHarvesterAzureAppInsightsKeyTest"; } else if (environment == EnvironmentSetting.Prod) { environmentVarName = "BloomHarvesterAzureAppInsightsKeyProd"; } string instrumentationKey = Environment.GetEnvironmentVariable(environmentVarName); Debug.Assert(!String.IsNullOrWhiteSpace(instrumentationKey), "Azure Instrumentation Key is invalid. Azure logging probably won't work."); try { Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey = instrumentationKey; } catch (ArgumentNullException e) { _issueReporter.ReportException(e, $"InstrumentationKey: {instrumentationKey ?? "null"}.\nenvironmentVarName: {environmentVarName}", null); } _telemetry.Context.User.Id = "BloomHarvester " + harvesterId; _telemetry.Context.Session.Id = Guid.NewGuid().ToString(); _telemetry.Context.Device.OperatingSystem = Environment.OSVersion.ToString(); string logFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "BloomHarvester", "log.txt"); Console.Out.WriteLine("Creating log file at: " + logFilePath); try { if (File.Exists(logFilePath)) { // Check if the file is too big (~10 MB) if (new FileInfo(logFilePath).Length > 10000000) { var oldPath = logFilePath + "-OLD"; // Preserve one previous log file for debugging help, and start over with // an empty log file. // (The data is in Azure too anyway, but having it local may speed things up.) if (RobustFile.Exists(oldPath)) { RobustFile.Delete(oldPath); } RobustFile.Move(logFilePath, oldPath); } } } catch { // Doesn't matter if there are any errors } try { _fileLogger = new FileLogger(logFilePath); } catch { // That's unfortunate that creating the logger failed, but I don't really want to throw an exception since the file logger isn't even the main purpose of this calss. // Let's just replace it with something to get it to be quiet. _fileLogger = new NullLogger(); } }