mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-23 00:56:45 +01:00
httpserver: More organized startup output (#2497)
* Move SiteOutput to a seperate function sorted by port. * Rename vars and tidy up * Move loopback note to output loop * Fix Typo * Remove unneeded var * Readability Change * Change to other port string. * Simplify as all sites in Server use the same port * Ensure -quiet supresses fmt.Println calls * Prevent double output of siteinfo to log - improve log message * change name of log in comment * Remove spaces * Remove extra line output * final tidy! * Use caddy.LogDestination to setup log * Ensure Log is still output if quiet. * Correct case of functions and make function param bool * Remove conditional check for LogDestination * Revert output to simple blocks * comment update
This commit is contained in:
parent
4f8020a94c
commit
98f160e39c
1 changed files with 22 additions and 4 deletions
|
@ -507,16 +507,34 @@ func (s *Server) Stop() error {
|
||||||
// OnStartupComplete lists the sites served by this server
|
// OnStartupComplete lists the sites served by this server
|
||||||
// and any relevant information, assuming caddy.Quiet == false.
|
// and any relevant information, assuming caddy.Quiet == false.
|
||||||
func (s *Server) OnStartupComplete() {
|
func (s *Server) OnStartupComplete() {
|
||||||
if caddy.Quiet {
|
if !caddy.Quiet {
|
||||||
return
|
firstSite := s.sites[0]
|
||||||
|
scheme := "HTTP"
|
||||||
|
if firstSite.TLS.Enabled {
|
||||||
|
scheme = "HTTPS"
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("")
|
||||||
|
fmt.Printf("Serving %s on port "+firstSite.Port()+" \n", scheme)
|
||||||
|
s.outputSiteInfo(false)
|
||||||
|
fmt.Println("")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Print out process log without header comment
|
||||||
|
s.outputSiteInfo(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) outputSiteInfo(isProcessLog bool) {
|
||||||
for _, site := range s.sites {
|
for _, site := range s.sites {
|
||||||
output := site.Addr.String()
|
output := site.Addr.String()
|
||||||
if caddy.IsLoopback(s.Address()) && !caddy.IsLoopback(site.Addr.Host) {
|
if caddy.IsLoopback(s.Address()) && !caddy.IsLoopback(site.Addr.Host) {
|
||||||
output += " (only accessible on this machine)"
|
output += " (only accessible on this machine)"
|
||||||
}
|
}
|
||||||
fmt.Println(output)
|
if isProcessLog {
|
||||||
log.Println(output)
|
log.Printf("[INFO] Serving %s \n", output)
|
||||||
|
} else {
|
||||||
|
fmt.Println(output)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue