Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lifecycle announcements setting #1083

Closed

Conversation

davwards
Copy link

@davwards davwards commented Jan 24, 2016

Resolves #1077, #1551 by adding a separate setting from :logging for folks who want to disable the startup/shutdown lifecycle announcements.

For users who are using Sinatra to fake out third party services in an
automated test suite, the startup/shutdown messages add clutter to test
output. However, users may want to disable logging without silencing
lifecycle announcements. So, add a separate option,
`:lifecycle_announcements`, which addresses the startup and shutdown
messages only.

The default value is set to true to preserve current behavior.
@davwards
Copy link
Author

Reviewing the original issue again, I realize this won't solve the issue entirely, because only Sinatra's part of the output is removed—the server's startup messages are still printed. Getting at those will probably be handler specific, though, so probably tricky.

@kgrz
Copy link
Member

kgrz commented Mar 9, 2016

@sinatra/team-sinatra how should we proceed with this?

@zzak
Copy link
Member

zzak commented Apr 13, 2016

The feature sounds good to me, but i'm not sold on the setting name.

Perhaps we could think about a new name?

Another option is to swallow stdout in this block in a way that would work for any handler (tests should help). Also, since we're bumping major we could change behavior to support unless logging? here instead of adding a setting.

@zzak zzak added the feature label Apr 13, 2016
@elifoster
Copy link

Wouldn't it be simpler to either make a function logging_enabled? for that load of conditions before all the puts calls, or a log(String) method so you don't need to remember all of the conditions you need to check before calling puts.

@zzak
Copy link
Member

zzak commented May 6, 2016

so you don't need to remember all of the conditions you need to check before calling puts.

As far as I can tell, it's only 2 places. Or am I missing something?

@elifoster
Copy link

It is, but that doesn't mean it won't be used in other places in the future.

@@ -1416,7 +1416,11 @@ def quit!
return unless running?
# Use Thin's hard #stop! if available, otherwise just #stop.
running_server.respond_to?(:stop!) ? running_server.stop! : running_server.stop
$stderr.puts "== Sinatra has ended his set (crowd applauds)" unless handler_name =~/cgi/i

unless lifecycle_announcements == false || handler_name =~/cgi/i
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about to use positive condition?

if lifecycle_announcements || handle_name !~ /cgi/g

Since that condition is used twice, what about to wrap it into some method?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the right positive condition is if lifecycle_announcements && handle_name !~ /cgi/g ?

@namusyaka namusyaka added this to the v2.1.0 milestone Feb 19, 2018
@namusyaka
Copy link
Member

Hmm, the concept of this change seems good to me. Can you rebase & fix an issue simi pointed out?

@jkowens
Copy link
Member

jkowens commented Mar 14, 2020

It looks like there is already a setting to disable these messages:

#1153

https://github.com/sinatra/sinatra#available-settings (quiet option)

@jkowens jkowens closed this Mar 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option to silently startup Sinatra server?
8 participants