// open will create or open the log specified by name
open will create or open the log specified by name
// open will create or open the log specified by name
func (s svc) open(logName string) (*zap.Logger, error) {
	log, err := os.OpenFile(s.LogPath+logName, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0666)
	if err != nil {
		return nil, fmt.Errorf("error opening log-file %s: %v", logName, err)
	}
	lumberjackLogger := &lumberjack.Logger{
		Filename:   log.Name(),
		MaxSize:    0, 
		MaxBackups: 3,
		MaxAge:     1, 
	}
	consoleConfig := zap.NewProductionEncoderConfig()
	consoleConfig.EncodeTime = zapcore.TimeEncoderOfLayout("2006-01-02 15:04:05.000 Z0700")
	consoleConfig.LineEnding = "\r\n"
	core := zapcore.NewCore(
		zapcore.NewJSONEncoder(consoleConfig),
		zapcore.AddSync(lumberjackLogger),
		zap.DebugLevel,
	)
	logger := zap.New(core)
	s.Holder[logName] = &Logholder{
		lastUsed: time.Now(),
		logger:   logger,
		lumber:   lumberjackLogger,
		file:     log,
	}
	return logger, nil
}
func ( s svc ) open ( logName string ) ( * zap . Logger , error ) { log , err := os . OpenFile ( s . LogPath + logName , os . O_WRONLY | os . O_CREATE | os . O_APPEND , 0666 ) if err != nil { return nil , fmt . Errorf ( " " , logName , err ) } lumberjackLogger := & lumberjack . Logger { Filename : log . Name ( ) , MaxSize : 0 , MaxBackups : 3 , MaxAge : 1 , } consoleConfig := zap . NewProductionEncoderConfig ( ) consoleConfig . EncodeTime = zapcore . TimeEncoderOfLayout ( " " ) consoleConfig . LineEnding = " \r \n " core := zapcore . NewCore ( zapcore . NewJSONEncoder ( consoleConfig ) , zapcore . AddSync ( lumberjackLogger ) , zap . DebugLevel , ) logger := zap . New ( core ) s . Holder [ logName ] = & Logholder { lastUsed : time . Now ( ) , logger : logger , lumber : lumberjackLogger , file : log , } return logger , nil }
open will create or open the log specified by name
open will create or open the log specified by name
// open or create the log file // megabytes //days // Use the same time stamp format as the Nuix logs do. // Use windows line endings so the the logs are shown properly in windows notepad.