//******************************************************************* // CONSTRUCTOR //******************************************************************* #region /// <summary> /// Construct a sink that saves logs to the specified Google PubSub account. /// </summary> /// <param name="options">Options configuring how the sink behaves, may NOT be null</param> public PeriodicGoogleCloudPubSubSink(GoogleCloudPubSubSinkOptions options ) : base(options.BatchPostingLimit, options.Period) { this._state = GoogleCloudPubSubSinkState.Create(options, null); }
//-------------- private void Initialize(GoogleCloudPubSubSinkOptions options) { //--- Mandatory options validations -------------------- this.ValidateMandatoryOptions(options); //--- // All is ok ... instances are created using the defined options... if (!options.BufferFileExtension.StartsWith(".")) options.BufferFileExtension = "." + options.BufferFileExtension; //--- RollingFileSink to store internal errors ------------------ // It will be generated a file for each day. string errorsFileExtension = (options.BufferFileExtension == ".log" ? ".errorlog" : ".log"); if (!string.IsNullOrWhiteSpace(options.ErrorBaseFilename)) { this._errorsRollingFileSink = new RollingFileSink( options.ErrorBaseFilename + CNST_Specifier_Separator + options.ErrorRollingSpecifier + errorsFileExtension, new GoogleCloudPubSubRawFormatter(), // Formatter for error info (raw). options.ErrorFileSizeLimitBytes, options.ErrorRetainedFileCountLimit ); } //--- this._state = GoogleCloudPubSubSinkState.Create(options, this._errorsRollingFileSink); this._shipper = new GoogleCloudPubSubLogShipper(this._state); //--- //--- RollingFileSink to store data to be sent to PubSub ------------------ // It will be generated a file for each day. this._dataRollingFileSink = new RollingFileSink( options.BufferBaseFilename + CNST_Specifier_Separator + options.BufferRollingSpecifier + options.BufferFileExtension, this._state.DurableFormatter, // Formatter for data to insert into the buffer file. options.BufferFileSizeLimitBytes, null ); // NOTE: if the encoding is set to UTF8 then the BOM is inserted into the file and has to be // taken in mind when reading from the file. }