1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- package go_chat_api_util
- import (
- "github.com/sirupsen/logrus"
- "io"
- )
- var log *logrus.Logger
- func NewLogger(f io.Writer) *logrus.Logger {
- log = logrus.New()
- log.Formatter = &logrus.JSONFormatter{}
-
-
-
-
- customF := new(logrus.JSONFormatter)
- customF.TimestampFormat = "2006-01-02 15:04:05"
- log.SetFormatter(customF)
- log.SetLevel(logrus.DebugLevel)
-
- log.Out = f
- return log
- }
- func GetMusk(phone string) string {
- if phone == "" {
- return phone
- }
- phoneMask := ""
- list := []byte(phone)
- lenS := len(phone)
- if lenS > 7 {
- asterisk := ""
- for i := 0; i < lenS-7; i++ {
- asterisk += "*"
- }
- phoneMask = string(list[:3]) + asterisk + string(list[lenS-4:])
- } else if lenS >= 5 {
- phoneMask = string(list[:2]) + "**" + string(list[lenS-2:])
- } else {
- phoneMask = phone
- }
- return phoneMask
- }
|