mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 01:47:33 +00:00
feat: add stdout and filesystem notification channels (#2925)
* feat: add filesystem and stdout notification channels * configure through env vars * compile * feat: add compact option for debug notification channels * fix channel mock generation * avoid sensitive information in error message Co-authored-by: Livio Amstutz <livio.a@gmail.com> * add review improvements Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
29
internal/notification/channels/log/channel.go
Normal file
29
internal/notification/channels/log/channel.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/k3a/html2text"
|
||||
|
||||
"github.com/caos/logging"
|
||||
"github.com/caos/zitadel/internal/notification/channels"
|
||||
)
|
||||
|
||||
func InitStdoutChannel(config LogConfig) channels.NotificationChannel {
|
||||
|
||||
logging.Log("NOTIF-D0164").Debug("successfully initialized stdout email and sms channel")
|
||||
|
||||
return channels.HandleMessageFunc(func(message channels.Message) error {
|
||||
|
||||
content := message.GetContent()
|
||||
if config.Compact {
|
||||
content = html2text.HTML2Text(content)
|
||||
}
|
||||
|
||||
logging.Log("NOTIF-c73ba").WithFields(map[string]interface{}{
|
||||
"type": fmt.Sprintf("%T", message),
|
||||
"content": content,
|
||||
}).Info("handling notification message")
|
||||
return nil
|
||||
})
|
||||
}
|
6
internal/notification/channels/log/config.go
Normal file
6
internal/notification/channels/log/config.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package log
|
||||
|
||||
type LogConfig struct {
|
||||
Enabled bool
|
||||
Compact bool
|
||||
}
|
Reference in New Issue
Block a user