当前位置: 首页>>代码示例>>Golang>>正文


Golang Logger.GetLogger函数代码示例

本文整理汇总了Golang中Logger.GetLogger函数的典型用法代码示例。如果您正苦于以下问题:Golang GetLogger函数的具体用法?Golang GetLogger怎么用?Golang GetLogger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetLogger函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: create

func (ms MusicServer) create(port string, indexFolder, musicFolder, addressMask, webfolder string) {
	ms.folder = indexFolder
	ms.textIndexer = music.LoadTextIndexer(ms.folder)
	ms.albumManager = music.NewAlbumManager(ms.folder)
	ms.webfolder = "resources/"
	if musicFolder != "" {
		ms.musicFolder = musicFolder
		if addressMask != "" {
			for i, val := range strings.Split(addressMask, ".") {
				if intVal, e := strconv.ParseInt(val, 10, 32); e == nil {
					ms.addressMask[i] = int(intVal)
				}
			}
		}
	}
	if webfolder != "" {
		ms.webfolder = webfolder
	}
	ms.dico = music.LoadDictionnary(ms.folder)
	if port == "" {
		logger.GetLogger().Fatal("Impossible to run node, port is not defined")
	}
	localIP := ms.findExposedURL()

	mux := ms.createRoutes()
	logger.GetLogger().Info("Runner ok on :", localIP, port)
	http.ListenAndServe(":"+port, mux)

	logger.GetLogger().Error("Runner ko")
}
开发者ID:jotitan,项目名称:music_server,代码行数:30,代码来源:music_server.go

示例2: IndexArtists

func IndexArtists(folder string) TextIndexer {
	// Recreate albums index at each time (very quick)
	artists := LoadArtists(folder)
	logger.GetLogger().Info("Launch index with", len(artists), "artists")
	dico := LoadDictionnary(folder)
	musicsByArtist := LoadArtistMusicIndex(folder)

	am := NewAlbumManager(folder)

	// Index album by genre (consider only one genre by album)

	for n, artistId := range artists {
		musicsIds := musicsByArtist.Get(artistId)
		// Load all tracks and group by album
		albums := make(map[string][]int)
		logger.GetLogger().Info("=>", n, artistId, dico.GetMusicsFromIds(musicsIds))
		for i, music := range dico.GetMusicsFromIds(musicsIds) {
			musicId := musicsIds[i]
			if ids, ok := albums[music["album"]]; ok {
				albums[music["album"]] = append(ids, musicId)
			} else {
				albums[music["album"]] = []int{musicId}
			}
			am.AddMusic(music["album"], musicId)
			am.IndexText(musicId, music["title"], music["artist"])
		}
		am.AddAlbumsByArtist(artistId, albums)
	}
	am.textIndexer.Build()
	am.Save()
	logger.GetLogger().Info("End index")
	return am.textIndexer
}
开发者ID:jotitan,项目名称:music_server,代码行数:33,代码来源:music_indexer.go

示例3: createServer

func createServer(port string) {
	if port == "" {
		logger.GetLogger().Fatal("Port is not defined")
	}
	localIP := findExposedURL()
	gameManager = longhorn.NewGameManager()
	mux := createRoutes()
	logger.GetLogger().Info("Runner ok on :", localIP, port)
	http.ListenAndServe(":"+port, mux)

	logger.GetLogger().Error("Runner ko")
}
开发者ID:jotitan,项目名称:longhorn,代码行数:12,代码来源:longhorn_server.go

示例4: readmusic

// Return music content
func (ms MusicServer) readmusic(response http.ResponseWriter, request *http.Request) {
	id, _ := strconv.ParseInt(request.FormValue("id"), 10, 32)
	logger.GetLogger().Info("Get music id", id)
	musicInfo := ms.dico.GetMusicFromId(int(id))

	m, _ := os.Open(musicInfo["path"])
	info, _ := m.Stat()
	logger.GetLogger().Info("load", musicInfo["path"])
	response.Header().Set("Content-type", "audio/mpeg")
	response.Header().Set("Content-Length", fmt.Sprintf("%d", info.Size()))
	io.Copy(response, m)
}
开发者ID:jotitan,项目名称:music_server,代码行数:13,代码来源:music_server.go

示例5: musicsInfo

// Return info about many musics
func (ms MusicServer) musicsInfo(response http.ResponseWriter, request *http.Request) {
	var ids []int
	json.Unmarshal([]byte(request.FormValue("ids")), &ids)
	logger.GetLogger().Info("Load musics", len(ids))

	ms.musicsResponse(ids, response)
}
开发者ID:jotitan,项目名称:music_server,代码行数:8,代码来源:music_server.go

示例6: LoadArtistIndex

// LoadArtistIndex Get artist index to search...
func LoadArtistIndex(folder string) ArtistIndex {
	ai := ArtistIndex{artists: make(map[string]int), artistsToSave: make([]string, 0)}
	ai.artists = LoadArtists(folder)
	ai.currentId = len(ai.artists) + 1
	logger.GetLogger().Info("Current artist id", ai.currentId)
	return ai
}
开发者ID:jotitan,项目名称:music_server,代码行数:8,代码来源:artist.go

示例7: checkRequester

func (ms MusicServer) checkRequester(request *http.Request) bool {
	addr := request.RemoteAddr[:strings.LastIndex(request.RemoteAddr, ":")]
	if "[::1]" != addr {
		// [::1] means localhost. Otherwise, compare to mask
		for i, val := range strings.Split(addr, ".") {
			if intval, e := strconv.ParseInt(val, 10, 32); e != nil {
				logger.GetLogger().Error("User attempt to update data from outside", request.Host, request.RemoteAddr)
				return false
			} else {
				if int(intval)&ms.addressMask[i] != int(intval) {
					logger.GetLogger().Error("User attempt to update data from outside", request.Host, request.RemoteAddr)
					return false
				}
			}
		}
	}
	return true
}
开发者ID:jotitan,项目名称:music_server,代码行数:18,代码来源:music_server.go

示例8: listByArtist

func (ms MusicServer) listByArtist(response http.ResponseWriter, request *http.Request) {
	if id := request.FormValue("id"); id == "" {
		ms.getAllArtists(response)
	} else {
		logger.GetLogger().Info("Load music of artist", id)
		artistId, _ := strconv.ParseInt(id, 10, 32)
		musicsIds := music.LoadArtistMusicIndex(ms.folder).MusicsByArtist[int(artistId)]
		ms.getMusics(response, musicsIds, false)
	}
}
开发者ID:jotitan,项目名称:music_server,代码行数:10,代码来源:music_server.go

示例9: CreateShareConnection

func CreateShareConnection(response http.ResponseWriter, deviceName, sessionId string) {
	createSSEHeader(response)
	// Generate unique code to receive order
	device := &Device{name: deviceName, response: response, sessionId: sessionId, connected: true}
	ss := &SharedSession{id: generateShareCode(), connected: true, original: device}
	sharedSessions[ss.id] = ss
	ss.original.send("id", fmt.Sprintf("%d", ss.id))
	logger.GetLogger().Info("Create share", ss.id)
	checkConnection(device)
	removeSharedSession(ss.id)
}
开发者ID:jotitan,项目名称:music_server,代码行数:11,代码来源:share.go

示例10: musicInfo

// Return info about music
func (ms MusicServer) musicInfo(response http.ResponseWriter, request *http.Request) {
	id, _ := strconv.ParseInt(request.FormValue("id"), 10, 32)
	logger.GetLogger().Info("Load music info with id", id)
	musicInfo := ms.dico.GetMusicFromId(int(id))
	delete(musicInfo, "path")
	musicInfo["id"] = fmt.Sprintf("%d", id)
	musicInfo["src"] = fmt.Sprintf("music?id=%d", id)
	bdata, _ := json.Marshal(musicInfo)
	writeCrossAccessHeader(response)
	response.Write(bdata)
}
开发者ID:jotitan,项目名称:music_server,代码行数:12,代码来源:music_server.go

示例11: Add

// Add the artist in index. Return id
func (ai *ArtistIndex) Add(artist string) int {
	// Check if exist
	if id, exist := ai.artists[artist]; exist {
		return id
	}
	id := ai.currentId
	ai.artists[artist] = id
	ai.artistsToSave = append(ai.artistsToSave, artist)
	logger.GetLogger().Info("Add artist", artist, " :", ai.currentId)
	ai.currentId++
	return id
}
开发者ID:jotitan,项目名称:music_server,代码行数:13,代码来源:artist.go

示例12: CountPoint

// boardCows contains nb of cows on board by color
func (p Player) CountPoint(boardCows []int) int {
	// Point if 100 for each color staying on board
	total := 0
	for i, nb := range p.Cows {
		total += boardCows[i] * 100 * int(nb)
	}
	for _, money := range p.Moneys {
		total += money
	}
	logger.GetLogger().Info("POINT", p.Id, p.Cows, boardCows, p.Moneys)
	return total
}
开发者ID:jotitan,项目名称:longhorn,代码行数:13,代码来源:player.go

示例13: getAllArtists

func (ms MusicServer) getAllArtists(response http.ResponseWriter) {
	logger.GetLogger().Info("Get all artists")
	// Response with nampe and url
	artists := music.LoadArtistIndex(ms.folder).FindAll()
	artistsData := make([]map[string]string, 0, len(artists))
	for artist, id := range artists {
		artistsData = append(artistsData, map[string]string{"name": artist, "url": fmt.Sprintf("id=%d", id)})
	}
	sort.Sort(sortByArtist(artistsData))
	bdata, _ := json.Marshal(artistsData)
	response.Write(bdata)
}
开发者ID:jotitan,项目名称:music_server,代码行数:12,代码来源:music_server.go

示例14: search

//search musics by free text
func (ms *MusicServer) search(response http.ResponseWriter, request *http.Request) {
	text := request.FormValue("term")
	size := float64(10)
	if s := request.FormValue("size"); s != "" {
		if intSize, e := strconv.ParseInt(s, 10, 32); e == nil {
			size = float64(intSize)
		}
	}
	musics := ms.textIndexer.Search(text)
	logger.GetLogger().Info("Search", text, len(musics))
	ms.musicsResponse(musics[:int(math.Min(size, float64(len(musics))))], response)
}
开发者ID:jotitan,项目名称:music_server,代码行数:13,代码来源:music_server.go

示例15: sessionID

func sessionID(response http.ResponseWriter, request *http.Request) string {
	if id := getSessionID(request); id != "" {
		return id
	}
	h := md5.New()
	h.Write([]byte(fmt.Sprintf("%d-%d", time.Now().Nanosecond(), rand.Int())))
	hash := h.Sum(nil)
	hexValue := hex.EncodeToString(hash)
	logger.GetLogger().Info("Set cookie session", hexValue)
	http.SetCookie(response, &http.Cookie{Name: "jsessionid", Value: hexValue})
	return hexValue
}
开发者ID:jotitan,项目名称:music_server,代码行数:12,代码来源:music_server.go


注:本文中的Logger.GetLogger函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。