Sha256: 0947388e292b70ddeb257226dee5cf6ef7d2d8cdcd8707f00be74b70ba77ffda
Contents?: true
Size: 1.61 KB
Versions: 2
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://github.com/BerkeleyLibrary/logging/releases) 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
berkeley_library-logging-0.2.2 | README.md |
berkeley_library-logging-0.2.1 | README.md |