Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

evanescent

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

evanescent

  • 1.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

evanescent

Build Status Gem Version GitHub issues GitHub license Downloads

Description

This gem provides an IO like object, that can be used with any logging class (such as Ruby's native Logger). This object will save its input to a file, and allows:

  • Hourly or daily rotation.
  • Compression of rotated files.
  • Removal of old compressed files.

This functionality supplement logging classes, allowing everything related to logging management, to be done within Ruby, without relying on external tools (such as logrotate).

Install

gem install evanescent

This gem uses Semantic Versioning, so you should add to your .gemspec something like:

  s.add_runtime_dependency 'evanescent', '~> 1.0'

Please, always check latest available version!

Example

Logger

require 'evanescent'
require 'timecop'

logger = Evanescent.logger(
  path: 'test.log',
  rotation: :hourly,
  keep: '2 hours',
)

logger.class # => Logger

# Within first hour, only test.log will exist.
Timecop.freeze(Time.now)
logger.info 'first message'
Dir.entries('.') # => [".", "..", "test.log"]

# One hour later, rotation and compression will happen.
Timecop.freeze(Time.now + 3600)
logger.info 'second message'
Dir.entries('.') # => [".", "..", "test.log", "test.log.2015122315.gz"]

# Another hour later, we'll have 2 compressed files.
Timecop.freeze(Time.now + 3600)
logger.info 'third message'
Dir.entries('.') # => [".", "..", "test.log", "test.log.2015122315.gz", "test.log.2015122316.gz"]

# At last, after keep period, old compressed files are purged.
Timecop.freeze(Time.now + 3600)
logger.info 'fourth message'
Dir.entries('.') # => [".", "..", "test.log", "test.log.2015122316.gz", "test.log.2015122317.gz"]

Generic usage

Evanescent is an IO like object: it responds to :write and :close:

io = Evanescent.new(
  path: 'test.log',
  rotation: :hourly,
  keep: '2 hours',
)
io.write('message') # writes message to test.log
io.close

Limitations

Although Evanescent supports mult-thread operation, inter-process locking is not currently implemented, and behavior is unpredicted in this situation.

FAQs

Package last updated on 23 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc