{"id":18319746,"url":"https://github.com/redding/logsly","last_synced_at":"2025-04-09T14:22:42.153Z","repository":{"id":5848797,"uuid":"7065350","full_name":"redding/logsly","owner":"redding","description":"Create custom loggers.","archived":false,"fork":false,"pushed_at":"2018-04-04T22:02:32.000Z","size":125,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-16T08:46:23.066Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/redding.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-12-08T08:01:33.000Z","updated_at":"2018-10-20T00:45:53.000Z","dependencies_parsed_at":"2022-08-31T17:12:19.280Z","dependency_job_id":null,"html_url":"https://github.com/redding/logsly","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redding%2Flogsly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redding%2Flogsly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redding%2Flogsly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redding%2Flogsly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/redding","download_url":"https://codeload.github.com/redding/logsly/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248054200,"owners_count":21039952,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T18:14:08.825Z","updated_at":"2025-04-09T14:22:42.103Z","avatar_url":"https://github.com/redding.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Logsly\n\nLogsly is a DSL and a mixin to setup and create custom logger objects.  Define your color schemes and log outputs.  Then mixin Logsly to make your logger classes.  Create instances of your loggers specifying outputs for each, then use your loggers to log stuff to those outputs.\n\n## Usage\n\n```ruby\n\n# define a named output for your logger to use\nLogsly.stdout('my_stdout')\n\n# define your logger\nclass MyLogger\n  include Logsly\nend\n\n# build a logger instance with a name and use it\nlogger = MyLogger.new(:outputs =\u003e ['my_stdout'])\nlogger.info \"whatever\"\n\n# build another logger and use it\nbg_logger = MyLogger.new('bg', :level =\u003e 'debug', :outputs =\u003e ['my_stdout'])\nbg_logger.debug \"something\"\n```\n\n## Implementation\n\nLogsly creates and delegates to a [Logging logger](https://github.com/TwP/logging/tree/logging-1.8.2).  When you create an instance of your logger class, Logsly sets up and configures Logging for you.\n\n**Note**: [Logging v1.8.2](https://github.com/TwP/logging/tree/logging-1.8.2) is the last version that is Ruby 1.8.7 compatible.  However, that version doesn't work in modern Ruby versions.  Therefore I've taken the source from Logging v1.8.2 and brought it in manually as a submodule under the `Logsly::Logging182` namespace.  I've tweaked the original source to allow properly requiring/referencing it as a submodule and to also make it work in modern Ruby.  All source in the `Logsly::Logging182` namespace is [MIT License Copyright (c) 2012 Tim Pease](https://github.com/TwP/logging/tree/logging-1.8.2#license) and all credit is his.\n\n## Settings\n\n* `log_type`: custom string used to identify the type of the logger\n* `level`: the level in use (default: `'info'`)\n* `outputs`: list of named outputs to log to (default: `[]`)\n\n## Outputs\n\n### Stdout\n\n```ruby\nLogsly.stdout('my_stdout') do |logger|\n  level   'info' # (optional) if set, this level will be used instead of the logger's setting\n  pattern '[%d %-5l] : %m\\n'\n  colors  'my_colors' # use the 'my_colors' color scheme\nend\n```\n\nDefine a named stdout output to use with your loggers.  Pass a block to customize it.  The block will be lazy-eval'd when a logger using it is initialized.  The block is passed the logger instance.\n\n### File\n\n```ruby\nLogsly.file('my_file') do |logger|\n  path \"development.log\"\n\n  level   'debug' # log debug level when outputting to this file\n  pattern '[%d %-5l] : %m\\n'\n  # don't use a color scheme\nend\n```\n\nDefine a named file output to use with your loggers.  Takes the same parameters as its stdout counterpart.  Specify the path (relative or absolute) to the log file using the `path` method.\n\n### Syslog\n\n```ruby\nLogsly.syslog('my_syslog') do |logger|\n  identity \"my_syslog_logger\" # or whatever\n  facility Syslog::LOG_LOCAL0 # or whatever (default: `LOG_LOCAL0`)\n  log_opts Syslog::LOG_PID    # or whatever (default: `(LOG_PID | LOG_CONS)`)\n\n  # no custom level set, just use the logger's setting\n  pattern '%m\\n'\n  # don't use a color scheme\nend\n```\n\nDefine a named syslog output to use with your loggers.  Takes the same parameters as its stdout counterpart.  Specify the identity and facility using the respective methods.\n\n### Patterns\n\nEach output can define what pattern to format its messages with using the `pattern' method.  See [Logging's patterns](https://github.com/TwP/logging/blob/logging-1.8.2/lib/logging/layouts/pattern.rb) for details.\n\n### Colors\n\n```ruby\nLogsly.colors('my_colors') do\n  debug :magenta\n  info  :cyan\n  warn  :yellow\n  error :red\n  fatal [:white, :on_red]\n\n  date    :blue\n  message :white\nend\n```\n\nDefine a named color scheme to use on your outputs.  Essentially creates a [Logging::ColorScheme](https://github.com/TwP/logging/blob/logging-1.8.2/lib/logging/color_scheme.rb) object.  See that file for configuration and details.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'logsly'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install logsly\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Added some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredding%2Flogsly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredding%2Flogsly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredding%2Flogsly/lists"}