* bootstrap encryption key * secret key message change in cli and secret key file content trimmed * Migrate encryption code to latest version * pull in newer code * tidying up * working data encryption layer * fix tests * remove stray comment * fix a few minor issues and improve the comments * split out databasefilename with param to two methods to be more obvious * DB encryption integration (#6374) * json methods moved under DBConnection * store encryption fixed * cleaned * review comments addressed * newstore value fixed * backup test updated * logrus format config updated * Fix for newStore Co-authored-by: Matt Hook <hookenz@gmail.com> * Minor improvements * Improve the export code. Add missing webhook for import * rename HelmUserRepositorys to HelmUserRepositories * fix logging messages * when starting portainer with a key (first use) http is disabled by default. But when starting fresh without a key, http is enabled? * Fix bug for default settings on new installs Co-authored-by: Prabhat Khera <prabhat.khera@portainer.io> Co-authored-by: Prabhat Khera <91852476+prabhat-org@users.noreply.github.com>
43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"strings"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
type portainerFormatter struct {
|
|
logrus.TextFormatter
|
|
}
|
|
|
|
func (f *portainerFormatter) Format(entry *logrus.Entry) ([]byte, error) {
|
|
var levelColor int
|
|
switch entry.Level {
|
|
case logrus.DebugLevel, logrus.TraceLevel:
|
|
levelColor = 31 // gray
|
|
case logrus.WarnLevel:
|
|
levelColor = 33 // yellow
|
|
case logrus.ErrorLevel, logrus.FatalLevel, logrus.PanicLevel:
|
|
levelColor = 31 // red
|
|
default:
|
|
levelColor = 36 // blue
|
|
}
|
|
return []byte(fmt.Sprintf("\x1b[%dm%s\x1b[0m %s %s\n", levelColor, strings.ToUpper(entry.Level.String()), entry.Time.Format(f.TimestampFormat), entry.Message)), nil
|
|
}
|
|
|
|
func configureLogger() {
|
|
logger := logrus.New() // logger is to implicitly substitute stdlib's log
|
|
log.SetOutput(logger.Writer())
|
|
|
|
formatter := &logrus.TextFormatter{DisableTimestamp: true, DisableLevelTruncation: true}
|
|
formatterLogrus := &portainerFormatter{logrus.TextFormatter{DisableTimestamp: false, DisableLevelTruncation: true, TimestampFormat: "2006/01/02 15:04:05", FullTimestamp: true}}
|
|
|
|
logger.SetFormatter(formatter)
|
|
logrus.SetFormatter(formatterLogrus)
|
|
|
|
logger.SetLevel(logrus.DebugLevel)
|
|
logrus.SetLevel(logrus.DebugLevel)
|
|
}
|