Low commit activity in last 3 years
No release in over a year
A gem providing shared logging code for UC Berkeley Library gems and Rails applications
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 4.9
~> 2.7
~> 1.2
>= 3.0.5, < 3.2
>= 6
~> 13.0
~> 1.26.0
~> 0.21.1

Runtime

~> 0.11
~> 1.8
~> 0.8.1
 Project Readme

BerkeleyLibrary::Logging

Build Status Gem Version

Opinionated logging for UCB Library IT Rails applications.

Usage

With Rails

BerkeleyLibrary::Logging is implemented as a Railtie, so adding it to your Gemfile should cause it to be loaded automatically.

With or without Rails

You can load BerkeleyLibrary::Logging explicitly with require:

require 'berkeley_library/logging'

logger = BerkeleyLibrary::Logging::Logger.default_logger

In a Rails environment, this will return the Rails logger (already configured by the Railtie); in a non-Rails environment, it will return a default, human-readable STDOUT logger.

Alternatively, you can create a logger directly:

require 'berkeley_library/logging'

logger = BerkeleyLibrary::Logging::Loggers.new_readable_logger('/tmp/mylog.log')
logger.warn('oops')
puts File.read('/tmp/mylog.log')

# => # Logfile created on 2021-02-03 16:47:06 -0800 by logger.rb/v1.4.2
     [2021-02-03T16:47:10.506-08:00] WARN: oops

logger = BerkeleyLibrary::Logging::Loggers.new_json_logger('/tmp/mylog.json')
logger.warn('oops')
puts File.read('/tmp/mylog.log')

# => # Logfile created on 2021-02-03 16:49:30 -0800 by logger.rb/v1.4.2
     {"name":"irb","hostname":"test.example.org","pid":7080,"level":40,"time":"2021-02-03T16:49:34.842-08:00","v":0,"severity":"WARN","msg":"oops"}