2022-01-06 08:00:24 +00:00
|
|
|
package log
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/k3a/html2text"
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/logging"
|
2024-04-03 10:43:43 +00:00
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/notification/channels"
|
2022-01-06 08:00:24 +00:00
|
|
|
)
|
|
|
|
|
2023-03-16 17:24:30 +00:00
|
|
|
func InitStdoutChannel(config Config) channels.NotificationChannel {
|
2022-01-06 08:00:24 +00:00
|
|
|
|
2024-07-26 20:39:55 +00:00
|
|
|
logging.WithFields("logID", "NOTIF-D0164").Debug("successfully initialized stdout email and sms channel")
|
2022-01-06 08:00:24 +00:00
|
|
|
|
|
|
|
return channels.HandleMessageFunc(func(message channels.Message) error {
|
|
|
|
|
2023-03-28 22:09:06 +00:00
|
|
|
content, err := message.GetContent()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2022-01-06 08:00:24 +00:00
|
|
|
if config.Compact {
|
|
|
|
content = html2text.HTML2Text(content)
|
|
|
|
}
|
|
|
|
|
2024-07-26 20:39:55 +00:00
|
|
|
logging.WithFields("logID", "NOTIF-c73ba").WithFields(map[string]interface{}{
|
2022-01-06 08:00:24 +00:00
|
|
|
"type": fmt.Sprintf("%T", message),
|
|
|
|
"content": content,
|
|
|
|
}).Info("handling notification message")
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|