Class: LogStash::Outputs::Qingstor::TemporaryFileFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/outputs/qingstor/temporary_file_factory.rb

Defined Under Namespace

Classes: IOWrappedGzip

Constant Summary collapse

FILE_MODE =
'a'.freeze
GZIP_ENCODING =
'gzip'.freeze
GZIP_EXTENSION =
'log.gz'.freeze
TXT_EXTENSION =
'log'.freeze
STRFTIME =
'%Y-%m-%dT%H.%M'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prefix, tags, encoding, tmpdir) ⇒ TemporaryFileFactory

Returns a new instance of TemporaryFileFactory.



22
23
24
25
26
27
28
29
30
31
# File 'lib/logstash/outputs/qingstor/temporary_file_factory.rb', line 22

def initialize(prefix, tags, encoding, tmpdir)
  @counter = 0
  @prefix = prefix
  @tags = tags
  @encoding = encoding
  @tmpdir = tmpdir
  @lock = Mutex.new

  rotate!
end

Instance Attribute Details

#counterObject

Returns the value of attribute counter.



20
21
22
# File 'lib/logstash/outputs/qingstor/temporary_file_factory.rb', line 20

def counter
  @counter
end

#currentObject

Returns the value of attribute current.



20
21
22
# File 'lib/logstash/outputs/qingstor/temporary_file_factory.rb', line 20

def current
  @current
end

#encodingObject

Returns the value of attribute encoding.



20
21
22
# File 'lib/logstash/outputs/qingstor/temporary_file_factory.rb', line 20

def encoding
  @encoding
end

#prefixObject

Returns the value of attribute prefix.



20
21
22
# File 'lib/logstash/outputs/qingstor/temporary_file_factory.rb', line 20

def prefix
  @prefix
end

#tagsObject

Returns the value of attribute tags.



20
21
22
# File 'lib/logstash/outputs/qingstor/temporary_file_factory.rb', line 20

def tags
  @tags
end

#tmpdirObject

Returns the value of attribute tmpdir.



20
21
22
# File 'lib/logstash/outputs/qingstor/temporary_file_factory.rb', line 20

def tmpdir
  @tmpdir
end

Instance Method Details

#rotate!Object



33
34
35
36
37
38
39
# File 'lib/logstash/outputs/qingstor/temporary_file_factory.rb', line 33

def rotate!
  @lock.synchronize do
    @current = new_file
    increment_counter
    @current
  end
end