mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 12:52:27 -05:00
Add optional syslog logrus hook (#343)
* add optional syslog logrus hook * document syslog
This commit is contained in:
parent
909f801742
commit
c111b239f7
38 changed files with 2242 additions and 37 deletions
|
|
@ -23,7 +23,6 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/superseriousbusiness/gotosocial/cmd/gotosocial/action"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/log"
|
||||
|
|
@ -52,12 +51,8 @@ func preRun(cmd *cobra.Command) error {
|
|||
// The idea here is to take a GTSAction and run it with the given
|
||||
// context, after initializing any last-minute things like loggers etc.
|
||||
func run(ctx context.Context, action action.GTSAction) error {
|
||||
// if log level has been set...
|
||||
if logLevel := viper.GetString(config.Keys.LogLevel); logLevel != "" {
|
||||
// then try to initialize the logger to that level
|
||||
if err := log.Initialize(logLevel); err != nil {
|
||||
return fmt.Errorf("error initializing log: %s", err)
|
||||
}
|
||||
if err := log.Initialize(); err != nil {
|
||||
return fmt.Errorf("error initializing log: %s", err)
|
||||
}
|
||||
|
||||
return action(ctx)
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ func Server(cmd *cobra.Command, values config.Values) {
|
|||
OIDC(cmd, values)
|
||||
SMTP(cmd, values)
|
||||
Router(cmd, values)
|
||||
Syslog(cmd, values)
|
||||
}
|
||||
|
||||
// Router attaches flags pertaining to the gin router.
|
||||
|
|
@ -109,3 +110,10 @@ func SMTP(cmd *cobra.Command, values config.Values) {
|
|||
cmd.Flags().String(config.Keys.SMTPPassword, values.SMTPPassword, usage.SMTPPassword)
|
||||
cmd.Flags().String(config.Keys.SMTPFrom, values.SMTPFrom, usage.SMTPFrom)
|
||||
}
|
||||
|
||||
// Syslog attaches flags pertaining to syslog config.
|
||||
func Syslog(cmd *cobra.Command, values config.Values) {
|
||||
cmd.Flags().Bool(config.Keys.SyslogEnabled, values.SyslogEnabled, usage.SyslogEnabled)
|
||||
cmd.Flags().String(config.Keys.SyslogProtocol, values.SyslogProtocol, usage.SyslogProtocol)
|
||||
cmd.Flags().String(config.Keys.SyslogAddress, values.SyslogAddress, usage.SyslogAddress)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,6 +73,9 @@ var usage = config.KeyNames{
|
|||
SMTPUsername: "Username to authenticate with the smtp server as. Eg., 'postmaster@mail.example.org'",
|
||||
SMTPPassword: "Password to pass to the smtp server.",
|
||||
SMTPFrom: "Address to use as the 'from' field of the email. Eg., 'gotosocial@example.org'",
|
||||
SyslogEnabled: "Enable the syslog logging hook. Logs will be mirrored to the configured destination.",
|
||||
SyslogProtocol: "Protocol to use when directing logs to syslog. Leave empty to connect to local syslog.",
|
||||
SyslogAddress: "Address:port to send syslog logs to. Leave empty to connect to local syslog.",
|
||||
AdminAccountUsername: "the username to create/delete/etc",
|
||||
AdminAccountEmail: "the email address of this account",
|
||||
AdminAccountPassword: "the password to set for this account",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue