func (l *Logger) Errorf(format string, args ...interface{}) {
	l.log(errorLevel, fmt.Sprintf(format, args...))
}
Errorf logs a message as error using format specifiers
package logger
import (
	"encoding/json"
	"fmt"
	"io"
	"os"
	"os/user"
	"strconv"
	"sync"
	"time"
)
const timestampFormat string = "2006-01-02T15:04:05.000Z07:00"
const debugLevel string = "DEBUG"
const infoLevel string = "INFO"
const errorLevel string = "ERROR"
type Logger struct {
	mutex       sync.Mutex
	writer      io.Writer
	debug       bool
	json        bool
	processName string
	pid         string
	serverName  string
	host        string
	userName    string
}
func NewLogger(writer io.Writer, debug bool, json bool, serverName string) (*Logger, error) {
	hostname, err := os.Hostname()
	if err != nil {
		return nil, err
	}
	user, err := user.Current()
	userName := ""
	if err == nil {
		userName = user.Username
	}
	return &Logger{
		mutex:       sync.Mutex{},
		writer:      writer,
		debug:       debug,
		json:        json,
		processName: os.Args[0],
		pid:         strconv.Itoa(os.Getpid()),
		serverName:  serverName,
		host:        hostname,
		userName:    userName,
	}, nil
}
func (l *Logger) format(entry map[string]interface{}) (string, error) {
	if l.json {
		b, err := json.Marshal(entry)
		if err != nil {
			return "", err
		}
		return string(b), err
	}
	return fmt.Sprintf("%v %v\n", entry["ibm_datetime"], entry["message"]), nil
}
func (l *Logger) log(level string, msg string) {
	t := time.Now()
	entry := map[string]interface{}{
		"message":         fmt.Sprint(msg),
		"ibm_datetime":    t.Format(timestampFormat),
		"loglevel":        level,
		"host":            l.host,
		"ibm_serverName":  l.serverName,
		"ibm_processName": l.processName,
		"ibm_processId":   l.pid,
		"ibm_userName":    l.userName,
		"type":            "mq_containerlog",
	}
	s, err := l.format(entry)
	l.mutex.Lock()
	if err != nil {
		fmt.Println(err)
	}
	if l.json {
		fmt.Fprintln(l.writer, s)
	} else {
		fmt.Fprint(l.writer, s)
	}
	l.mutex.Unlock()
}
func (l *Logger) Debug(args ...interface{}) {
	if l.debug {
		if l.json {
			l.log(debugLevel, fmt.Sprint(args...))
		} else {
			l.log(debugLevel, "DEBUG: "+fmt.Sprint(args...))
		}
	}
}
func (l *Logger) Debugf(format string, args ...interface{}) {
	if l.debug {
		if l.json {
			l.log(debugLevel, fmt.Sprintf(format, args...))
		} else {
			l.log(debugLevel, fmt.Sprintf("DEBUG: "+format, args...))
		}
	}
}
func (l *Logger) Print(args ...interface{}) {
	l.log(infoLevel, fmt.Sprint(args...))
}
func (l *Logger) Println(args ...interface{}) {
	l.Print(args...)
}
func (l *Logger) Printf(format string, args ...interface{}) {
	l.log(infoLevel, fmt.Sprintf(format, args...))
}
func (l *Logger) PrintString(msg string) {
	l.log(infoLevel, msg)
}
func (l *Logger) Error(args ...interface{}) {
	l.log(errorLevel, fmt.Sprint(args...))
}