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


Java Logger.error方法代码示例

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


在下文中一共展示了Logger.error方法的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: getFollowedVideos

import com.jcabi.log.Logger; //导入方法依赖的package包/类
/**
 * Endpoint: Get Followed Videos
 * Gets the videos from channels the user is following based on the OAuth token provided.
 * Requires Scope: user_read
 *
 * @param oAuthCredential The user.
 * @param broadcast_type Constrains the type of videos returned. Valid values: (any combination of) archive, highlight, upload, Default: highlight. (comma-separated list)
 * @return Gets the videos from channels the user is following based on the OAuth token provided.
 */
public List<Video> getFollowedVideos(OAuthCredential oAuthCredential, Optional<String> broadcast_type) {
	// Endpoint
	String requestUrl = String.format("%s/videos/followed", Endpoints.API.getURL());
	RestTemplate restTemplate = getTwitchClient().getRestClient().getPrivilegedRestTemplate(oAuthCredential);

	// Parameters
	restTemplate.getInterceptors().add(new QueryRequestInterceptor("broadcast_type", broadcast_type.orElse("highlight")));

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

		return responseObject.getVideos();
	} 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,代码来源:VideoEndpoint.java

示例3: 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

示例4: getTeams

import com.jcabi.log.Logger; //导入方法依赖的package包/类
/**
 * Endpoint: Get All Teams
 * Gets all active teams.
 * Requires Scope: none
 *
 * @param limit  Maximum number of most-recent objects to return. Default: 25. Maximum: 100.
 * @param offset Object offset for pagination. Default is 0.
 * @return todo
 */
public List<Team> getTeams(Optional<Long> limit, Optional<Long> offset) {
	// Endpoint
	String requestUrl = String.format("%s/teams", 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()));

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

		return responseObject.getTeams();
	} 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,代码行数:34,代码来源:TeamEndpoint.java

示例5: 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

示例6: 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

示例7: getEmber

import com.jcabi.log.Logger; //导入方法依赖的package包/类
/**
 * Gets the primary team for a channel, which is displayed in the channel.
 *
 * @param userName Twitch username
 * @return todo
 */
public Ember getEmber(String userName) {
	// Endpoint
	String requestUrl = String.format("https://api.twitch.tv/api/channels/%s/ember", userName);
	RestTemplate restTemplate = getTwitchClient().getRestClient().getRestTemplate();

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

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

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

示例8: 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

示例9: getTeams

import com.jcabi.log.Logger; //导入方法依赖的package包/类
/**
 * Endpoint: Get Channel Teams
 * Gets a list of teams to which a specified channel belongs.
 * Requires Scope: none
 *
 * @return todo
 */
public List<Team> getTeams() {
	// Endpoint
	String requestUrl = String.format("%s/channels/%s/teams", Endpoints.API.getURL(), getChannelId());
	RestTemplate restTemplate = getTwitchClient().getRestClient().getRestTemplate();

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

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

示例10: checkUserFollowByChannel

import com.jcabi.log.Logger; //导入方法依赖的package包/类
/**
 * Endpoint: Check User Follows by Channel
 * Checks if a specified user follows a specified channel. If the user is following the channel, a follow object is returned.
 * Requires Scope: none
 *
 * @param userId    UserID as Long
 * @param channelId ChannelID as Long
 * @return Optional Follow, if user is following.
 */
public Optional<Follow> checkUserFollowByChannel(Long userId, Long channelId) {
	// Endpoint
	String requestUrl = String.format("%s/users/%s/follows/channels/%s", Endpoints.API.getURL(), userId, channelId);
	RestTemplate restTemplate = getTwitchClient().getRestClient().getRestTemplate();

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

		return Optional.ofNullable(responseObject);
	} catch (RestException restException) {
		if (restException.getRestError().getStatus().equals(404)) {
			// User does not follow channel
			return Optional.empty();
		} 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

示例11: unfollowChannel

import com.jcabi.log.Logger; //导入方法依赖的package包/类
/**
 * Endpoint: Unfollow Channel
 * Deletes a specified user from the followers of a specified channel.
 * Requires Scope: user_follows_edit
 *
 * @param credential Credential
 * @param channelId  Channel to follow
 * @return Optional Follow, if user is following.
 */
public Boolean unfollowChannel(OAuthCredential credential, Long channelId) {
	// Endpoint
	String requestUrl = String.format("%s/users/%s/follows/channels/%s", Endpoints.API.getURL(), credential.getUserId(), channelId);
	RestTemplate restTemplate = getTwitchClient().getRestClient().getPrivilegedRestTemplate(credential);

	// REST Request
	try {
		Logger.trace(this, "Rest Request to [%s]", requestUrl);
		restTemplate.delete(requestUrl);

		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

示例12: getToken

import com.jcabi.log.Logger; //导入方法依赖的package包/类
/**
 * Endpoint: Get OAuth Token Information
 * Gets information about the provided oAuthToken
 * Requires Scope: none
 *
 * @param credential The credential the information should be fetched for.
 * @return Information about the user, that issued the token - also provides info about scopes/valid/etc.
 * @see Token
 */
public Token getToken(OAuthCredential credential) {
	// Endpoint
	String requestUrl = String.format("%s", Endpoints.API.getURL());
	RestTemplate restTemplate = getTwitchClient().getRestClient().getPrivilegedRestTemplate(credential);

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

		return responseObject.getToken();
	} 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));
	}

	// Default Response: Invalid Token
	return new Token();
}
 
开发者ID:twitch4j,项目名称:twitch4j,代码行数:30,代码来源:KrakenEndpoint.java

示例13: getIngestServer

import com.jcabi.log.Logger; //导入方法依赖的package包/类
/**
 * Endpoint: Get Ingest Server List
 * Gets a list of Twitch ingest servers.
 * The Twitch ingesting system is the first stop for a broadcast stream. An ingest server receives your stream, and the
 * ingesting system authorizes and registers streams, then prepares them for viewers.
 * Requires Scope: none
 *
 * @return todo
 */
public List<Ingest> getIngestServer() {
	// Endpoint
	String requestUrl = String.format("%s/ingests", Endpoints.API.getURL());
	RestTemplate restTemplate = getTwitchClient().getRestClient().getRestTemplate();

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

		return responseObject.getIngests();
	} 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,代码行数:30,代码来源:IngestEndpoint.java

示例14: getByChannel

import com.jcabi.log.Logger; //导入方法依赖的package包/类
/**
 * Get Stream by Channel
 * <p>
 * Gets stream information (the stream object) for a specified channel.
 * Requires Scope: none
 *
 * @param channel Get stream object of Channel Entity
 * @return Optional of type Stream is only Present if Stream is Online, returns Optional.empty for Offline streams
 */
public Optional<Stream> getByChannel(Channel channel) {
	// Endpoint
	String requestUrl = String.format("%s/streams/%s", Endpoints.API.getURL(), channel.getId());
	RestTemplate restTemplate = getTwitchClient().getRestClient().getRestTemplate();

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

		// Stream Offline
		if (responseObject.getStream() == null) {
			// Stream Offline
			return Optional.empty();
		} else {
			// Stream Online
			return Optional.ofNullable(responseObject.getStream());
		}

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

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

示例15: 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


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