Exemple #1
0
func (logmoserv *LogmoServer) startConsole() error {
	console, err := logmo.GetAdapter("console")
	if err == nil {
		return errors.New("A adapter with the same name already exists on the logmo")
	}

	def, err := logmo.GetAdapter("default")
	if err == nil {
		def.Destroy()
		logmo.DeleteAdapter("default")
	}

	console = logmo.NewAdapterConsole(10000)
	console.AddHook("level", &logmo.HookLevel{byte(logmoserv.LogLevel)})
	logmoserv.adapter = console
	console.Run()
	return nil
}
Exemple #2
0
func (logmoserv *LogmoServer) startFile() error {
	_, err := logmo.GetAdapter("file")
	if err == nil {
		return errors.New("A adapter with the same name already exists on the logmo")
	}

	if logmoserv.LogFile == "" {
		return errors.New("LogFile is empty")
	}

	file := logmo.NewAdapterFile(10000)
	file.Filename = logmoserv.LogFile
	file.MaxLine = logmoserv.MaxLine
	file.MaxSize = logmoserv.MaxSize
	file.MaxDays = logmoserv.MaxDays
	file.Rotation = logmoserv.Rotation
	file.AddHook("level", &logmo.HookLevel{byte(logmoserv.LogLevel)})
	logmoserv.adapter = file
	file.Run()
	return nil
}