Sha256: 9f59b92182c7e803d57c5c0861e653623db77d06267c3c1c75b90b5d78b432f6
Contents?: true
Size: 1.61 KB
Versions: 7
Compression:
Stored size: 1.61 KB
Contents
# BerkeleyLibrary::Logging [![Build Status](https://github.com/BerkeleyLibrary/logging/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/BerkeleyLibrary/logging/actions/workflows/build.yml) [![Gem Version](https://img.shields.io/gem/v/berkeley_library-logging.svg)](https://rubygems.org/gems/berkeley_library-logging/) 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`: ```ruby 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: ```ruby 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"} ```
Version data entries
7 entries across 7 versions & 1 rubygems