Skip to content
This repository has been archived by the owner on Jan 29, 2022. It is now read-only.

Commit

Permalink
Add log level options
Browse files Browse the repository at this point in the history
  • Loading branch information
dhollinger committed Aug 3, 2020
1 parent 12ba249 commit a2e1187
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,14 @@ type: Boolean
description: Allow uppercase within the name of the module or environment passed to the API.
default: true

### Logging Settings

#### `loglevel`

type: String
description: Set the Logging level for the application. Valid values are `debug`, `error`, `warn`, `fatal`, and `info`.
default `warn`

### Configure the webhook

This API provides two endpoints that need to be called:
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require 'github_changelog_generator/task'

namespace :db do
task :load_config do
require './config/environment.rb'
require './app/controllers/application_controller'
end

Expand Down
6 changes: 5 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ class ApplicationController < Sinatra::Base
set :database, "sqlite3:db/#{ENV['SINATRA_ENV']}.sqlite3"
set :public_folder, 'public'
set :views, 'app/views'
set :logger, Logger.new(STDOUT)

# Logging settings
logger = Logger.new(STDOUT)
logger.level = PuppetWebhook.loglevel
set :logger, logger
end

not_found do
Expand Down
3 changes: 3 additions & 0 deletions config/config.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ development:
ignore_environments: []
allow_uppercase: true

# Logging
loglevel: debug

test: &development
16 changes: 16 additions & 0 deletions lib/puppet_webhook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@
require_relative 'puppet_webhook/orchestrators'
require_relative 'puppet_webhook/chatops'

# Module to contain the PuppetWebhook library.
module PuppetWebhook
VERSION = '2.1.2'

def self.loglevel
case APP_CONFIG.loglevel
when 'debug'
Logger::DEBUG
when 'info'
Logger::INFO
when 'error'
Logger::ERROR
when 'fatal'
Logger::FATAL
else
Logger::WARN
end
end
end

0 comments on commit a2e1187

Please sign in to comment.