• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SimpleLog类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



SimpleLog类属于net.dv8tion.jda.utils包,在下文中一共展示了SimpleLog类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getResults

import net.dv8tion.jda.utils.SimpleLog; //导入依赖的package包/类
public List<String> getResults(String query, int numresults)
{
    List<String> urls = new ArrayList<>();
    search.setQ(query);
    search.setMaxResults((long)numresults);
    
    SearchListResponse searchResponse;
    try {
        searchResponse = search.execute();
    List<SearchResult> searchResultList = searchResponse.getItems();
    searchResultList.stream().forEach((sr) -> {
        urls.add(sr.getId().getVideoId());
    });
    } catch (IOException ex) {
        SimpleLog.getLog("Youtube").fatal("Search failure: "+ex.toString());
        return null;
    }
    return urls;
}
 
开发者ID:jagrosh,项目名称:Spectra,代码行数:20,代码来源:YoutubeSearcher.java


示例2: Launcher

import net.dv8tion.jda.utils.SimpleLog; //导入依赖的package包/类
@Autowired
public Launcher(Config config, SocketServer socketServer) {
    Runtime.getRuntime().addShutdownHook(new Thread(() -> {
        log.info("Shutdown hook triggered");
        try {
            socketServer.stop(30);
        } catch (InterruptedException e) {
            log.warn("Interrupted while stopping socket server", e);
        }
    }, "shutdown hook"));

    SimpleLog.LEVEL = SimpleLog.Level.OFF;
    SimpleLog.addListener(new SimpleLogToSLF4JAdapter());
    Launcher.config = config;
    initSentry();
    this.socketServer = socketServer;
}
 
开发者ID:Frederikam,项目名称:Lavalink,代码行数:18,代码来源:Launcher.java


示例3: YoutubeSearcher

import net.dv8tion.jda.utils.SimpleLog; //导入依赖的package包/类
public YoutubeSearcher(String apiKey)
{
    youtube = new YouTube.Builder(new NetHttpTransport(), new JacksonFactory(), (HttpRequest request) -> {
    }).setApplicationName(SpConst.BOTNAME).build();
    Search.List tmp = null;
    try {
        tmp = youtube.search().list("id,snippet");
    } catch (IOException ex) {
        SimpleLog.getLog("Youtube").fatal("Failed to initialize search: "+ex.toString());
    }
    search = tmp;
    if(search!=null)
    {
        search.setKey(apiKey);
        search.setType("video");
        search.setFields("items(id/kind,id/videoId,snippet/title,snippet/thumbnails/default/url)");
    }
}
 
开发者ID:jagrosh,项目名称:Spectra,代码行数:19,代码来源:YoutubeSearcher.java


示例4: onLog

import net.dv8tion.jda.utils.SimpleLog; //导入依赖的package包/类
@Override
public void onLog(SimpleLog simpleLog, SimpleLog.Level logLevel, Object message) {
    if (message == null) {
        message = "null";
    }

    switch (logLevel) {
        case TRACE:
            if (log.isTraceEnabled()) {
                log.trace(message.toString());
            }
            break;
        case DEBUG:
            if (log.isDebugEnabled()) {
                log.debug(message.toString());
            }
            break;
        case INFO:
            log.info(message.toString());
            break;
        case WARNING:
            log.warn(message.toString());
            break;
        case FATAL:
            log.error(message.toString());
            break;
    }
}
 
开发者ID:Frederikam,项目名称:Lavalink,代码行数:29,代码来源:SimpleLogToSLF4JAdapter.java


示例5: onError

import net.dv8tion.jda.utils.SimpleLog; //导入依赖的package包/类
@Override
public void onError(SimpleLog simpleLog, Throwable err) {
    log.error("An exception occurred", err);
}
 
开发者ID:Frederikam,项目名称:Lavalink,代码行数:5,代码来源:SimpleLogToSLF4JAdapter.java


示例6: main

import net.dv8tion.jda.utils.SimpleLog; //导入依赖的package包/类
public static void main(final String[] args) throws Exception {
    try {
        SimpleLog.addFileLogs(null,new File("err" + System.currentTimeMillis() + ".txt"));
    } catch (IOException e) {
        Logger.writeToErr(e, "");
    }
    Dao dao = new Dao();
    List<Platform> platforms;
    String token = PropertiesReader.getInstance().getProp().getProperty("bot.token");
    DiscordController discordController = new DiscordController(dao);
    JDA jda = new JDABuilder()
            .setBotToken(token)
            .addListener(discordController)
            .buildBlocking();
    discordController.setJda(jda);

    Thread messageConsumer = new MessageConsumer(MessageHandler.getQueue(), jda, dao);
    messageConsumer.start();

    Thread messageFinder = new MessageFinder(MessageHandler.getDeleteQueue(), jda);
    messageFinder.start();

    platforms = setPlatforms(dao, jda);

    WebController webController = new WebController(jda, dao);
    webController.serve();

    platforms.forEach(Platform::checkStillOnline);
    int ticks = 0;
    while(true){

        if(!((JDAImpl)jda).getClient().isConnected()){
            while (!((JDAImpl)jda).getClient().isConnected()){
                Thread.sleep(1000);
            }
            discordController.setJda(jda);
            platforms = setPlatforms(dao, jda);
            //webController.setJda(jda);
            continue;
        }

        if(!messageConsumer.isAlive()){
            messageConsumer = new MessageConsumer(MessageHandler.getQueue(), jda, dao);
            messageConsumer.start();
        }

        if(!messageFinder.isAlive()){
            messageFinder = new MessageFinder(MessageHandler.getDeleteQueue(), jda);
            messageFinder.start();
        }

        if(ticks < 10){
            Session session = HibernateUtil.getSession();
            List<Long> guildIDs = session.createCriteria(GuildEntity.class)
                    .setProjection(Projections.property("id")).list();
            List<Guild> connectedGuilds = jda.getGuilds();
            for(Guild connectedGuild : connectedGuilds){
                Long connectedGuildID = Long.parseLong(connectedGuild.getId());
                if(guildIDs.contains(connectedGuildID)){
                    for(Platform platform : platforms){
                        platform.checkStreams(connectedGuildID);
                    }
                }
            }
            ticks++;
        }
        else{
            platforms.forEach(Platform::checkStillOnline);
            ticks = 0;
        }

        Thread.sleep(60000);


    }

}
 
开发者ID:Gyoo,项目名称:Discord-Streambot,代码行数:78,代码来源:Main.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SpellDictionary类代码示例发布时间:2022-05-23
下一篇:
Java ClientCertRequest类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap