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


Java Logger.trace方法代码示例

本文整理汇总了Java中com.jcabi.log.Logger.trace方法的典型用法代码示例。如果您正苦于以下问题:Java Logger.trace方法的具体用法?Java Logger.trace怎么用?Java Logger.trace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jcabi.log.Logger的用法示例。


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

示例1: getChatters

import com.jcabi.log.Logger; //导入方法依赖的package包/类
/**
 * Gets all user's present in the twitch chat of a channel.
 *
 * @param channelName Channel to fetch the information for.
 * @return All chatters in a channel, separated into groups like admins, moderators and viewers.
 */
public Chatter getChatters(String channelName) {
	// Endpoint
	String requestUrl = String.format("%s/group/user/%s/chatters", Endpoints.TMI.getURL(), channelName);
	RestTemplate restTemplate = getTwitchClient().getRestClient().getRestTemplate();

	// REST Request
	try {
		if (!restObjectCache.containsKey(requestUrl)) {
			Logger.trace(this, "Rest Request to [%s]", requestUrl);
			ChatterResult responseObject = restTemplate.getForObject(requestUrl, ChatterResult.class);
			restObjectCache.put(requestUrl, responseObject, ExpirationPolicy.CREATED, 60, TimeUnit.SECONDS);
		}

		return ((ChatterResult) restObjectCache.get(requestUrl)).getChatters();

	} catch (RestException restException) {
		Logger.error(this, "RestException: " + restException.getRestError().toString());
	} catch (Exception ex) {
		Logger.error(this, "Request failed: " + ex.getMessage());
		Logger.trace(this, ExceptionUtils.getStackTrace(ex));
	}

	// OnError: Return empty result
	return new Chatter();
}
 
开发者ID:twitch4j,项目名称:twitch4j,代码行数:32,代码来源:TMIEndpoint.java

示例2: getGames

import com.jcabi.log.Logger; //导入方法依赖的package包/类
/**
 * Endpoint: Search Games
 * Searches for games based on a specified query parameter. A game is returned if the query parameter is matched entirely or partially, in the game name.
 * Requires Scope: none
 *
 * @param query search query
 * @param live Whether only games that are live should be returned. This argument is optional.
 * @return A list of games matching the query.
 */
public List<Game> getGames(String query, Optional<Boolean> live) {
	// Endpoint
	String requestUrl = String.format("%s/search/games", Endpoints.API.getURL());
	RestTemplate restTemplate = getTwitchClient().getRestClient().getRestTemplate();

	// Parameters
	restTemplate.getInterceptors().add(new QueryRequestInterceptor("query", query));
	restTemplate.getInterceptors().add(new QueryRequestInterceptor("live", live.orElse(false).toString()));

	// REST Request
	try {
		GameList responseObject = restTemplate.getForObject(requestUrl, GameList.class);

		return responseObject.getGames();
	} catch (RestException restException) {
		Logger.error(this, "RestException: " + restException.getRestError().toString());
	} catch (Exception ex) {
		Logger.error(this, "Request failed: " + ex.getMessage());
		Logger.trace(this, ExceptionUtils.getStackTrace(ex));
	}

	return null;
}
 
开发者ID:twitch4j,项目名称:twitch4j,代码行数:33,代码来源:SearchEndpoint.java

示例3: getUser

import com.jcabi.log.Logger; //导入方法依赖的package包/类
/**
 * Endpoint to get Privileged User Information
 *
 * @param credential todo
 * @return todo
 */
public Optional<User> getUser(OAuthCredential credential) {
	// Validate Arguments
	Assert.notNull(credential, "Please provide Twitch Credentials!");

	// Endpoint
	String requestUrl = String.format("%s/user", Endpoints.API.getURL());
	RestTemplate restTemplate = getTwitchClient().getRestClient().getPrivilegedRestTemplate(credential);

	// REST Request
	try {
		Logger.trace(this, "Rest Request to [%s]", requestUrl);
		User responseObject = restTemplate.getForObject(requestUrl, User.class);

		return Optional.ofNullable(responseObject);
	} catch (RestException restException) {
		Logger.error(this, "RestException: " + restException.getRestError().toString());
	} catch (Exception ex) {
		Logger.error(this, "Request failed: " + ex.getMessage());
		Logger.trace(this, ExceptionUtils.getStackTrace(ex));
	}

	return Optional.empty();
}
 
开发者ID:twitch4j,项目名称:twitch4j,代码行数:30,代码来源:UserEndpoint.java

示例4: getConnectedSteamProfile

import com.jcabi.log.Logger; //导入方法依赖的package包/类
/**
 * Gets the steam profile id, if the streamer has linked his steam account.
 *
 * @param userName Twitch username
 * @return todo
 */
public String getConnectedSteamProfile(String userName) {
	// Endpoint
	String requestUrl = String.format("https://api.twitch.tv/api/channels/%s", userName);
	RestTemplate restTemplate = getTwitchClient().getRestClient().getRestTemplate();

	// REST Request
	try {
		Logger.trace(this, "Rest Request to [%s]", requestUrl);
		AdvancedChannelInformation responseObject = restTemplate.getForObject(requestUrl, AdvancedChannelInformation.class);

		return responseObject.getSteamId();
	} catch (Exception ex) {
		Logger.error(this, "Request failed: " + ex.getMessage());
		Logger.trace(this, ExceptionUtils.getStackTrace(ex));
	}

	return null;
}
 
开发者ID:twitch4j,项目名称:twitch4j,代码行数:25,代码来源:UnofficialEndpoint.java

示例5: getTopGames

import com.jcabi.log.Logger; //导入方法依赖的package包/类
/**
 * Endpoint: Get Top Games
 * Get games by number of current viewers on Twitch.
 * Requires Scope: none
 *
 * @return todo
 */
public List<TopGame> getTopGames() {
	// Endpoint
	String requestUrl = String.format("%s/games/top", Endpoints.API.getURL());
	RestTemplate restTemplate = getTwitchClient().getRestClient().getRestTemplate();

	// REST Request
	try {
		Logger.trace(this, "Rest Request to [%s]", requestUrl);
		TopGameList responseObject = restTemplate.getForObject(requestUrl, TopGameList.class);

		return responseObject.getTop();
	} catch (Exception ex) {
		Logger.error(this, "Request failed: " + ex.getMessage());
		Logger.trace(this, ExceptionUtils.getStackTrace(ex));
	}

	return null;
}
 
开发者ID:twitch4j,项目名称:twitch4j,代码行数:26,代码来源:GameEndpoint.java

示例6: addBlock

import com.jcabi.log.Logger; //导入方法依赖的package包/类
/**
 * Endpoint: Block User
 * Blocks a user; that is, adds a specified target user to the blocks list of a specified source user.
 * Requires Scope: user_blocks_edit
 *
 * @param credential   Credential
 * @param targetUserId UserID of the Target
 * @return todo
 */
public Boolean addBlock(OAuthCredential credential, Long targetUserId) {
	// Endpoint
	String requestUrl = String.format("%s/users/%s/blocks/%s", Endpoints.API.getURL(), credential.getUserId(), targetUserId);
	RestTemplate restTemplate = getTwitchClient().getRestClient().getPrivilegedRestTemplate(credential);

	// REST Request
	try {
		Logger.trace(this, "Rest Request to [%s]", requestUrl);
		restTemplate.put(requestUrl, Follow.class, new HashMap<String, String>());

		return true;
	} catch (RestException restException) {
		Logger.error(this, "RestException: " + restException.getRestError().toString());
	} catch (Exception ex) {
		Logger.error(this, "Request failed: " + ex.getMessage());
		Logger.trace(this, ExceptionUtils.getStackTrace(ex));
	}

	return false;
}
 
开发者ID:twitch4j,项目名称:twitch4j,代码行数:30,代码来源:UserEndpoint.java

示例7: updateCommunity

import com.jcabi.log.Logger; //导入方法依赖的package包/类
/**
 * Endpoint: Update Community
 * Creates a community.
 * Requires Scope: none
 *
 * @param credential  OAuth token for a Twitch user (that as 2fa enabled)
 * @param id          Id of the community, which will be updated.
 * @param name        Community name. 3-25 characters, which can be alphanumerics, dashes (-), periods (.), underscores (_), and tildes (~). Cannot contain spaces.
 * @param summary     Short description of the community, shown in search results. Maximum: 160 characters.
 * @param description Long description of the community, shown in the *about this community* box. Markdown syntax allowed. Maximum 1,572,864 characters (1.5 MB).
 * @param rules       Rules displayed when viewing a community page or searching for a community from the broadcaster dashboard. Markdown syntax allowed. Maximum 1,572,864 characters (1.5 MB)
 * @param email       Email address of the community owner.
 */
public void updateCommunity(OAuthCredential credential, String id, Optional<String> name, Optional<String> summary, Optional<String> description, Optional<String> rules, Optional<String> email) {
	// Endpoint
	String requestUrl = String.format("%s/communities/%s", Endpoints.API.getURL());
	RestTemplate restTemplate = getTwitchClient().getRestClient().getRestTemplate();

	// Post Data
	MultiValueMap<String, Object> postBody = new LinkedMultiValueMap<String, Object>();
	postBody.add("summary", summary.orElse(""));
	postBody.add("description", description.orElse(""));
	postBody.add("rules", rules.orElse(""));
	postBody.add("email", email.orElse(""));

	// REST Request
	try {
		restTemplate.postForObject(requestUrl, postBody, CommunityCreate.class);
	} catch (RestException restException) {
		Logger.error(this, "RestException: " + restException.getRestError().toString());
	} catch (Exception ex) {
		Logger.error(this, "Request failed: " + ex.getMessage());
		Logger.trace(this, ExceptionUtils.getStackTrace(ex));
	}

	return;
}
 
开发者ID:twitch4j,项目名称:twitch4j,代码行数:38,代码来源:CommunityEndpoint.java

示例8: getUserSubcriptionCheck

import com.jcabi.log.Logger; //导入方法依赖的package包/类
/**
 * Endpoint: Check User Subscription by Channel
 * Checks if a specified user is subscribed to a specified channel.
 * Requires Scope: user_subscriptions
 *
 * @param userId    UserId of the user.
 * @param channelId ChannelId of the channel you are checking against.
 * @return Optional of Type UserSubscriptionCheck. Is only present, when the user is subscribed.
 */
public Optional<UserSubscriptionCheck> getUserSubcriptionCheck(Long userId, Long channelId) {
	// Endpoint
	String requestUrl = String.format("%s/users/%s/subscriptions/%s", Endpoints.API.getURL(), userId, channelId);
	RestTemplate restTemplate = getTwitchClient().getRestClient().getRestTemplate();

	// REST Request
	try {
		Logger.trace(this, "Rest Request to [%s]", requestUrl);
		UserSubscriptionCheck responseObject = restTemplate.getForObject(requestUrl, UserSubscriptionCheck.class);

		return Optional.ofNullable(responseObject);
	} catch (RestException restException) {
		if (restException.getRestError().getStatus().equals(422)) {
			// Channel has no subscription program.
			Logger.info(this, "Channel %s has no subscription programm.", channelId);
		} else {
			Logger.error(this, "RestException: " + restException.getRestError().toString());
		}
	} catch (Exception ex) {
		Logger.error(this, "Request failed: " + ex.getMessage());
		Logger.trace(this, ExceptionUtils.getStackTrace(ex));
	}

	return Optional.empty();
}
 
开发者ID:twitch4j,项目名称:twitch4j,代码行数:35,代码来源:UserEndpoint.java

示例9: getChannels

import com.jcabi.log.Logger; //导入方法依赖的package包/类
/**
 * Endpoint: Search Channels
 * Searches for channels based on a specified query parameter. A channel is returned if the query parameter is matched entirely or partially, in the channel description or game name.
 * Requires Scope: none
 *
 * @param query search query
 * @param limit Maximum number of most-recent objects to return. Default: 25. Maximum: 100.
 * @return A list of Channels matching the query.
 */
public List<Channel> getChannels(String query, Optional<Long> limit) {
	// Endpoint
	String requestUrl = String.format("%s/search/channels", Endpoints.API.getURL());
	RestTemplate restTemplate = getTwitchClient().getRestClient().getRestTemplate();

	// Parameters
	restTemplate.getInterceptors().add(new QueryRequestInterceptor("limit", limit.orElse(25l).toString()));
	restTemplate.getInterceptors().add(new QueryRequestInterceptor("query", query));

	// REST Request
	try {
		ChannelList responseObject = restTemplate.getForObject(requestUrl, ChannelList.class);

		return responseObject.getChannels();
	} catch (RestException restException) {
		Logger.error(this, "RestException: " + restException.getRestError().toString());
	} catch (Exception ex) {
		Logger.error(this, "Request failed: " + ex.getMessage());
		Logger.trace(this, ExceptionUtils.getStackTrace(ex));
	}

	return null;
}
 
开发者ID:twitch4j,项目名称:twitch4j,代码行数:33,代码来源:SearchEndpoint.java

示例10: getVideos

import com.jcabi.log.Logger; //导入方法依赖的package包/类
/**
 * Endpoint: Get Channel Videos
 * Gets a list of videos from a specified channel.
 * Requires Scope: none
 *
 * @param limit          Maximum number of most-recent objects to return. Default: 25. Maximum: 100.
 * @param offset         Object offset for pagination of results. Default: 0.
 * @param sort           Sorting order of the returned objects. Valid values: views, time. Default: time (most recent first).
 * @param language       Constrains the language of the videos that are returned; for example, *en,es.* Default: all languages.
 * @param broadcast_type Constrains the type of videos returned. Valid values: (any combination of) archive, highlight, upload, Default: highlight.
 * @return todo
 */
public List<Video> getVideos(Optional<Long> limit, Optional<Long> offset, Optional<String> sort, Optional<String> language, Optional<String> broadcast_type) {
	// Endpoint
	String requestUrl = String.format("%s/channels/%s/videos", Endpoints.API.getURL(), getChannelId());
	RestTemplate restTemplate = getTwitchClient().getRestClient().getRestTemplate();

	// Parameters
	restTemplate.getInterceptors().add(new QueryRequestInterceptor("limit", limit.orElse(25l).toString()));
	restTemplate.getInterceptors().add(new QueryRequestInterceptor("offset", offset.orElse(0l).toString()));
	restTemplate.getInterceptors().add(new QueryRequestInterceptor("sort", sort.orElse("time").toString()));
	restTemplate.getInterceptors().add(new QueryRequestInterceptor("language", language.orElse(null).toString()));
	restTemplate.getInterceptors().add(new QueryRequestInterceptor("broadcast_type", broadcast_type.orElse("highlight").toString()));

	// REST Request
	try {
		VideoList responseObject = restTemplate.getForObject(requestUrl, VideoList.class);

		return responseObject.getVideos();
	} catch (Exception ex) {
		Logger.error(this, "Request failed: " + ex.getMessage());
		Logger.trace(this, ExceptionUtils.getStackTrace(ex));
		return null;
	}
}
 
开发者ID:twitch4j,项目名称:twitch4j,代码行数:36,代码来源:ChannelEndpoint.java

示例11: getCommunityByName

import com.jcabi.log.Logger; //导入方法依赖的package包/类
/**
 * Endpoint: Get Community by Name
 * Gets a specified community.
 * Requires Scope: none
 *
 * @param name The name of the community is specified in a required query-string parameter. It must be 3-25 characters.
 * @return todo
 */
public Community getCommunityByName(String name) {
	// Endpoint
	String requestUrl = String.format("%s/communities", Endpoints.API.getURL());
	RestTemplate restTemplate = getTwitchClient().getRestClient().getRestTemplate();

	// Parameter
	restTemplate.getInterceptors().add(new QueryRequestInterceptor("name", name));

	// REST Request
	try {
		Community responseObject = restTemplate.getForObject(requestUrl, Community.class);

		return responseObject;
	} catch (RestException restException) {
		Logger.error(this, "RestException: " + restException.getRestError().toString());
	} catch (Exception ex) {
		Logger.error(this, "Request failed: " + ex.getMessage());
		Logger.trace(this, ExceptionUtils.getStackTrace(ex));
	}

	return null;
}
 
开发者ID:twitch4j,项目名称:twitch4j,代码行数:31,代码来源:CommunityEndpoint.java

示例12: getAll

import com.jcabi.log.Logger; //导入方法依赖的package包/类
/**
 * Get All Streams (ordered by current viewers, desc)
 * <p>
 * Gets the list of all live streams.
 * Requires Scope: none
 *
 * @param limit       Maximum number of most-recent objects to return. Default: 25. Maximum: 100.
 * @param offset      Object offset for pagination of results. Default: 0.
 * @param language    Restricts the returned streams to the specified language. Permitted values are locale ID strings, e.g. en, fi, es-mx.
 * @param game        Restricts the returned streams to the specified game.
 * @param channelIds  Receives the streams from a comma-separated list of channel IDs.
 * @param stream_type Restricts the returned streams to a certain stream type. Valid values: live, playlist, all. Playlists are offline streams of VODs (Video on Demand) that appear live. Default: live.
 * @return Returns all streams that match with the provided filtering.
 */
public List<Stream> getAll(Optional<Long> limit, Optional<Long> offset, Optional<String> language, Optional<Game> game, Optional<String> channelIds, Optional<String> stream_type) {
	// Endpoint
	String requestUrl = String.format("%s/streams", Endpoints.API.getURL());
	RestTemplate restTemplate = getTwitchClient().getRestClient().getRestTemplate();

	// Parameters
	restTemplate.getInterceptors().add(new QueryRequestInterceptor("limit", limit.orElse(25l).toString()));
	restTemplate.getInterceptors().add(new QueryRequestInterceptor("offset", offset.orElse(0l).toString()));
	restTemplate.getInterceptors().add(new QueryRequestInterceptor("language", language.orElse(null)));
	restTemplate.getInterceptors().add(new QueryRequestInterceptor("game", game.map(Game::getName).orElse(null)));
	restTemplate.getInterceptors().add(new QueryRequestInterceptor("channel", channelIds.isPresent() ? channelIds.get() : null));
	restTemplate.getInterceptors().add(new QueryRequestInterceptor("stream_type", stream_type.orElse("all")));

	// REST Request
	try {
		StreamList responseObject = restTemplate.getForObject(requestUrl, StreamList.class);

		return responseObject.getStreams();
	} catch (Exception ex) {
		Logger.error(this, "Request failed: " + ex.getMessage());
		Logger.trace(this, ExceptionUtils.getStackTrace(ex));
	}

	return null;
}
 
开发者ID:twitch4j,项目名称:twitch4j,代码行数:40,代码来源:StreamEndpoint.java

示例13: getFollowed

import com.jcabi.log.Logger; //导入方法依赖的package包/类
/**
 * Get Followed Streams
 * <p>
 * Gets the list of online streams a user follows based on the OAuthTwitch token provided.
 * Requires Scope: user_read
 *
 * @param credential The user.
 * @return All streams as user follows.
 */
public List<Stream> getFollowed(OAuthCredential credential) {
	// Endpoint
	String requestUrl = String.format("%s/streams/followed", Endpoints.API.getURL());
	RestTemplate restTemplate = getTwitchClient().getRestClient().getPrivilegedRestTemplate(credential);

	// REST Request
	try {
		StreamList responseObject = restTemplate.getForObject(requestUrl, StreamList.class);

		return responseObject.getStreams();
	} catch (Exception ex) {
		Logger.error(this, "Request failed: " + ex.getMessage());
		Logger.trace(this, ExceptionUtils.getStackTrace(ex));
	}

	return new ArrayList<Stream>();
}
 
开发者ID:twitch4j,项目名称:twitch4j,代码行数:27,代码来源:StreamEndpoint.java

示例14: getSummary

import com.jcabi.log.Logger; //导入方法依赖的package包/类
/**
 * Get Streams Summary
 * <p>
 * Gets a summary of all live streams.
 * Requires Scope: none
 *
 * @param game Restricts the summary stats to the specified game.
 * @return A <code>StreamSummary</code> object, that contains the total number of live streams and viewers.
 */
public StreamSummary getSummary(Optional<Game> game) {
	// Endpoint
	String requestUrl = String.format("%s/streams/summary", Endpoints.API.getURL());
	RestTemplate restTemplate = getTwitchClient().getRestClient().getRestTemplate();

	// Parameters
	restTemplate.getInterceptors().add(new QueryRequestInterceptor("game", game.map(Game::getName).orElse("")));

	// REST Request
	try {
		Logger.trace(this, "Rest Request to [%s]", requestUrl);
		StreamSummary responseObject = restTemplate.getForObject(requestUrl, StreamSummary.class);

		return responseObject;
	} catch (RestException restException) {
		Logger.error(this, "RestException: " + restException.getRestError().toString());
	} catch (Exception ex) {
		Logger.error(this, "Request failed: " + ex.getMessage());
		Logger.trace(this, ExceptionUtils.getStackTrace(ex));
	}

	return null;
}
 
开发者ID:twitch4j,项目名称:twitch4j,代码行数:33,代码来源:StreamEndpoint.java

示例15: getCommunityById

import com.jcabi.log.Logger; //导入方法依赖的package包/类
/**
 * Endpoint: Get Community by ID
 * Gets a specified community.
 * Requires Scope: none
 *
 * @param id The guid of the community. (e9f17055-810f-4736-ba40-fba4ac541caa)
 * @return The community.
 */
public Community getCommunityById(String id) {
	// Endpoint
	String requestUrl = String.format("%s/communities/%s", Endpoints.API.getURL(), id);
	RestTemplate restTemplate = getTwitchClient().getRestClient().getRestTemplate();

	// REST Request
	try {
		Community responseObject = restTemplate.getForObject(requestUrl, Community.class);

		return responseObject;
	} catch (RestException restException) {
		Logger.error(this, "RestException: " + restException.getRestError().toString());
	} catch (Exception ex) {
		Logger.error(this, "Request failed: " + ex.getMessage());
		Logger.trace(this, ExceptionUtils.getStackTrace(ex));
	}

	return null;
}
 
开发者ID:twitch4j,项目名称:twitch4j,代码行数:28,代码来源:CommunityEndpoint.java


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