3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-13 07:29:30 +01:00

Merge pull request #339 from slingamn/startuplog

rename the "startup", "rehash", and "shutdown" log types to "server"
This commit is contained in:
Daniel Oaks 2019-02-03 12:37:24 +10:00 committed by GitHub
commit e7399ba2b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 31 deletions

View File

@ -1885,13 +1885,13 @@ func quitHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp
// REHASH // REHASH
func rehashHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool { func rehashHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
server.logger.Info("rehash", fmt.Sprintf("REHASH command used by %s", client.nick)) server.logger.Info("server", fmt.Sprintf("REHASH command used by %s", client.nick))
err := server.rehash() err := server.rehash()
if err == nil { if err == nil {
rb.Add(nil, server.name, RPL_REHASHING, client.nick, "ircd.yaml", client.t("Rehashing")) rb.Add(nil, server.name, RPL_REHASHING, client.nick, "ircd.yaml", client.t("Rehashing"))
} else { } else {
server.logger.Error("rehash", fmt.Sprintln("Failed to rehash:", err.Error())) server.logger.Error("server", fmt.Sprintln("Failed to rehash:", err.Error()))
rb.Add(nil, server.name, ERR_UNKNOWNERROR, client.nick, "REHASH", err.Error()) rb.Add(nil, server.name, ERR_UNKNOWNERROR, client.nick, "REHASH", err.Error())
} }
return false return false

View File

@ -235,10 +235,10 @@ func (server *Server) Run() {
case <-server.rehashSignal: case <-server.rehashSignal:
go func() { go func() {
server.logger.Info("rehash", "Rehashing due to SIGHUP") server.logger.Info("server", "Rehashing due to SIGHUP")
err := server.rehash() err := server.rehash()
if err != nil { if err != nil {
server.logger.Error("rehash", fmt.Sprintln("Failed to rehash:", err.Error())) server.logger.Error("server", fmt.Sprintln("Failed to rehash:", err.Error()))
} }
}() }()
} }
@ -567,13 +567,13 @@ func whoChannel(client *Client, channel *Channel, friends ClientSet, rb *Respons
// rehash reloads the config and applies the changes from the config file. // rehash reloads the config and applies the changes from the config file.
func (server *Server) rehash() error { func (server *Server) rehash() error {
server.logger.Debug("rehash", "Starting rehash") server.logger.Debug("server", "Starting rehash")
// only let one REHASH go on at a time // only let one REHASH go on at a time
server.rehashMutex.Lock() server.rehashMutex.Lock()
defer server.rehashMutex.Unlock() defer server.rehashMutex.Unlock()
server.logger.Debug("rehash", "Got rehash lock") server.logger.Debug("server", "Got rehash lock")
config, err := LoadConfig(server.configFilename) config, err := LoadConfig(server.configFilename)
if err != nil { if err != nil {
@ -607,7 +607,7 @@ func (server *Server) applyConfig(config *Config, initial bool) (err error) {
} }
// sanity checks complete, start modifying server state // sanity checks complete, start modifying server state
server.logger.Info("rehash", "Using config file", server.configFilename) server.logger.Info("server", "Using config file", server.configFilename)
oldConfig := server.Config() oldConfig := server.Config()
// first, reload config sections for functionality implemented in subpackages: // first, reload config sections for functionality implemented in subpackages:
@ -649,7 +649,7 @@ func (server *Server) applyConfig(config *Config, initial bool) (err error) {
} }
} }
newLanguageValue := strings.Join(langCodes, ",") newLanguageValue := strings.Join(langCodes, ",")
server.logger.Debug("rehash", "Languages:", newLanguageValue) server.logger.Debug("server", "Languages:", newLanguageValue)
if currentLanguageValue != newLanguageValue { if currentLanguageValue != newLanguageValue {
updatedCaps.Add(caps.Languages) updatedCaps.Add(caps.Languages)
@ -658,7 +658,7 @@ func (server *Server) applyConfig(config *Config, initial bool) (err error) {
lm := languages.NewManager(config.Languages.Default, config.Languages.Data) lm := languages.NewManager(config.Languages.Default, config.Languages.Data)
server.logger.Debug("rehash", "Regenerating HELP indexes for new languages") server.logger.Debug("server", "Regenerating HELP indexes for new languages")
GenerateHelpIndices(lm) GenerateHelpIndices(lm)
server.languages = lm server.languages = lm
@ -700,7 +700,7 @@ func (server *Server) applyConfig(config *Config, initial bool) (err error) {
stsValue := config.Server.STS.Value() stsValue := config.Server.STS.Value()
stsDisabledByRehash := false stsDisabledByRehash := false
stsCurrentCapValue, _ := CapValues.Get(caps.STS) stsCurrentCapValue, _ := CapValues.Get(caps.STS)
server.logger.Debug("rehash", "STS Vals", stsCurrentCapValue, stsValue, fmt.Sprintf("server[%v] config[%v]", stsPreviouslyEnabled, config.Server.STS.Enabled)) server.logger.Debug("server", "STS Vals", stsCurrentCapValue, stsValue, fmt.Sprintf("server[%v] config[%v]", stsPreviouslyEnabled, config.Server.STS.Enabled))
if config.Server.STS.Enabled && !stsPreviouslyEnabled { if config.Server.STS.Enabled && !stsPreviouslyEnabled {
// enabling STS // enabling STS
SupportedCapabilities.Enable(caps.STS) SupportedCapabilities.Enable(caps.STS)
@ -738,7 +738,7 @@ func (server *Server) applyConfig(config *Config, initial bool) (err error) {
// updated caps get DEL'd and then NEW'd // updated caps get DEL'd and then NEW'd
// so, we can just add updated ones to both removed and added lists here and they'll be correctly handled // so, we can just add updated ones to both removed and added lists here and they'll be correctly handled
server.logger.Debug("rehash", "Updated Caps", updatedCaps.String(caps.Cap301, CapValues)) server.logger.Debug("server", "Updated Caps", updatedCaps.String(caps.Cap301, CapValues))
addedCaps.Union(updatedCaps) addedCaps.Union(updatedCaps)
removedCaps.Union(updatedCaps) removedCaps.Union(updatedCaps)
@ -779,7 +779,7 @@ func (server *Server) applyConfig(config *Config, initial bool) (err error) {
server.config = config server.config = config
server.configurableStateMutex.Unlock() server.configurableStateMutex.Unlock()
server.logger.Info("rehash", "Using datastore", config.Datastore.Path) server.logger.Info("server", "Using datastore", config.Datastore.Path)
if initial { if initial {
if err := server.loadDatastore(config); err != nil { if err := server.loadDatastore(config); err != nil {
return err return err
@ -825,7 +825,7 @@ func (server *Server) setupPprofListener(config *Config) {
} }
if server.pprofServer != nil { if server.pprofServer != nil {
if pprofListener == "" || (pprofListener != server.pprofServer.Addr) { if pprofListener == "" || (pprofListener != server.pprofServer.Addr) {
server.logger.Info("rehash", "Stopping pprof listener", server.pprofServer.Addr) server.logger.Info("server", "Stopping pprof listener", server.pprofServer.Addr)
server.pprofServer.Close() server.pprofServer.Close()
server.pprofServer = nil server.pprofServer = nil
} }
@ -836,16 +836,16 @@ func (server *Server) setupPprofListener(config *Config) {
} }
go func() { go func() {
if err := ps.ListenAndServe(); err != nil { if err := ps.ListenAndServe(); err != nil {
server.logger.Error("rehash", "pprof listener failed", err.Error()) server.logger.Error("server", "pprof listener failed", err.Error())
} }
}() }()
server.pprofServer = &ps server.pprofServer = &ps
server.logger.Info("rehash", "Started pprof listener", server.pprofServer.Addr) server.logger.Info("server", "Started pprof listener", server.pprofServer.Addr)
} }
} }
func (server *Server) loadMOTD(motdPath string, useFormatting bool) error { func (server *Server) loadMOTD(motdPath string, useFormatting bool) error {
server.logger.Info("rehash", "Using MOTD", motdPath) server.logger.Info("server", "Using MOTD", motdPath)
motdLines := make([]string, 0) motdLines := make([]string, 0)
if motdPath != "" { if motdPath != "" {
file, err := os.Open(motdPath) file, err := os.Open(motdPath)
@ -887,7 +887,7 @@ func (server *Server) loadDatastore(config *Config) error {
_, err := os.Stat(config.Datastore.Path) _, err := os.Stat(config.Datastore.Path)
if os.IsNotExist(err) { if os.IsNotExist(err) {
server.logger.Warning("rehash", "database does not exist, creating it", config.Datastore.Path) server.logger.Warning("server", "database does not exist, creating it", config.Datastore.Path)
err = initializeDB(config.Datastore.Path) err = initializeDB(config.Datastore.Path)
if err != nil { if err != nil {
return err return err
@ -902,7 +902,7 @@ func (server *Server) loadDatastore(config *Config) error {
} }
// load *lines (from the datastores) // load *lines (from the datastores)
server.logger.Debug("rehash", "Loading D/Klines") server.logger.Debug("server", "Loading D/Klines")
server.loadDLines() server.loadDLines()
server.loadKLines() server.loadKLines()
@ -922,7 +922,7 @@ func (server *Server) setupListeners(config *Config) (err error) {
tlsListeners, err := config.TLSListeners() tlsListeners, err := config.TLSListeners()
if err != nil { if err != nil {
server.logger.Error("rehash", "failed to reload TLS certificates, aborting rehash", err.Error()) server.logger.Error("server", "failed to reload TLS certificates, aborting rehash", err.Error())
return return
} }
@ -964,7 +964,7 @@ func (server *Server) setupListeners(config *Config) (err error) {
tlsConfig := tlsListeners[newaddr] tlsConfig := tlsListeners[newaddr]
listener, listenerErr := server.createListener(newaddr, tlsConfig, config.Server.UnixBindMode) listener, listenerErr := server.createListener(newaddr, tlsConfig, config.Server.UnixBindMode)
if listenerErr != nil { if listenerErr != nil {
server.logger.Error("rehash", "couldn't listen on", newaddr, listenerErr.Error()) server.logger.Error("server", "couldn't listen on", newaddr, listenerErr.Error())
err = listenerErr err = listenerErr
continue continue
} }
@ -974,7 +974,7 @@ func (server *Server) setupListeners(config *Config) (err error) {
} }
if len(tlsListeners) == 0 { if len(tlsListeners) == 0 {
server.logger.Warning("rehash", "You are not exposing an SSL/TLS listening port. You should expose at least one port (typically 6697) to accept TLS connections") server.logger.Warning("server", "You are not exposing an SSL/TLS listening port. You should expose at least one port (typically 6697) to accept TLS connections")
} }
var usesStandardTLSPort bool var usesStandardTLSPort bool
@ -985,7 +985,7 @@ func (server *Server) setupListeners(config *Config) (err error) {
} }
} }
if 0 < len(tlsListeners) && !usesStandardTLSPort { if 0 < len(tlsListeners) && !usesStandardTLSPort {
server.logger.Warning("rehash", "Port 6697 is the standard TLS port for IRC. You should (also) expose port 6697 as a TLS port to ensure clients can connect securely") server.logger.Warning("server", "Port 6697 is the standard TLS port for IRC. You should (also) expose port 6697 as a TLS port to ensure clients can connect securely")
} }
return return

View File

@ -130,11 +130,11 @@ Options:
} }
} else if arguments["run"].(bool) { } else if arguments["run"].(bool) {
if !arguments["--quiet"].(bool) { if !arguments["--quiet"].(bool) {
logman.Info("startup", fmt.Sprintf("Oragono v%s starting", irc.SemVer)) logman.Info("server", fmt.Sprintf("Oragono v%s starting", irc.SemVer))
if commit == "" { if commit == "" {
logman.Debug("startup", fmt.Sprintf("Could not get current commit")) logman.Debug("server", fmt.Sprintf("Could not get current commit"))
} else { } else {
logman.Info("startup", fmt.Sprintf("Running commit %s", commit)) logman.Info("server", fmt.Sprintf("Running commit %s", commit))
} }
} }
@ -146,17 +146,17 @@ Options:
// warning if running a non-final version // warning if running a non-final version
if strings.Contains(irc.SemVer, "unreleased") { if strings.Contains(irc.SemVer, "unreleased") {
logman.Warning("startup", "You are currently running an unreleased beta version of Oragono that may be unstable and could corrupt your database.\nIf you are running a production network, please download the latest build from https://oragono.io/downloads.html and run that instead.") logman.Warning("server", "You are currently running an unreleased beta version of Oragono that may be unstable and could corrupt your database.\nIf you are running a production network, please download the latest build from https://oragono.io/downloads.html and run that instead.")
} }
server, err := irc.NewServer(config, logman) server, err := irc.NewServer(config, logman)
if err != nil { if err != nil {
logman.Error("startup", fmt.Sprintf("Could not load server: %s", err.Error())) logman.Error("server", fmt.Sprintf("Could not load server: %s", err.Error()))
return os.Exit(1)
} }
if !arguments["--quiet"].(bool) { if !arguments["--quiet"].(bool) {
logman.Info("startup", "Server running") logman.Info("server", "Server running")
defer logman.Info("shutdown", fmt.Sprintf("Oragono v%s exiting", irc.SemVer)) defer logman.Info("server", fmt.Sprintf("Oragono v%s exiting", irc.SemVer))
} }
server.Run() server.Run()
} }

View File

@ -354,12 +354,12 @@ logging:
# #
# useful types include: # useful types include:
# * everything (usually used with exclusing some types below) # * everything (usually used with exclusing some types below)
# server server startup, rehash, and shutdown events
# accounts account registration and authentication # accounts account registration and authentication
# channels channel creation and operations # channels channel creation and operations
# commands command calling and operations # commands command calling and operations
# opers oper actions, authentication, etc # opers oper actions, authentication, etc
# password password hashing and comparing # password password hashing and comparing
# rehash server startup and rehash events
# userinput raw lines sent by users # userinput raw lines sent by users
# useroutput raw lines sent to users # useroutput raw lines sent to users
type: "* -userinput -useroutput -localconnect -localconnect-ip" type: "* -userinput -useroutput -localconnect -localconnect-ip"