设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 58|回复: 0

[转载发布] Liquid Logging Utility

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    慵懒
    3 天前
  • 签到天数: 207 天

    连续签到: 1 天

    [LV.7]常住居民III

    3646

    主题

    862

    回帖

    2万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    21262
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    25800

    灌水之王

    发表于 3 天前 | 显示全部楼层 |阅读模式
    Liquid Logging - Version 1.0
    Liquidize

    Introduction
    Coming from a C#/Unity and C++ background, I felt the need to personally have a way to have better formatted log information in the console when debugging my scripts and events.

    This may not serve much for a lot of you, but I figured I'd release it for those that it would serve well too. So I give you, Liquid_Logging. An extensible logging system for scripters and eventers to use

    when debugging, or just to log information nicely! This is a logging system built similarly too logging systems like Log4Net, in that it is able to have different types of custom formatters and appenders created.

    Ever wanted to be able to log stuff too files, or to a server? Well if the appender exists for this (it doesn't yet, maybe when I get the time <3) you can do just that. Basically this is a plugin that allows things to be logged to the console (and again, if you wanted too go a head and make the appender, custom things like files). 

    Features

    - The ability to log formatted messages and objects to any built in appender (Developer Console for example).

    - The ability to specify the format used as a pattern string.

    - The ability to log messages from events using a plugin command.

    - The ability to create custom appenders and formatters to suit your needs.


    Screenshots
    Console Appender Output Example: http://puu.sh/l7Se3.png

    Event Page Plugin Command Example: http://puu.sh/l7SeG.png (generates the above screenshot)

    How to Use
    For better instructions, see the help menu for the script in the plugin manager.

    Using In Your Own Scripts (One way)

    Spoiler // Script setup stuff above this code... (didn't want too include it)   // Variable to see if logging is available.  var logging = false; var mySuperDuperLogger = null;  if (Imported.Liquid_Logging) {    mySuperDuperLogger = Liquid.Logging.getLogger("MySuperDuperLog");    var mySuperDuperAppender = new Liquid_ConsoleAppender();    var mySuperDuperFormat = new Liquid_PatternFormat("[%d{HH:mm:ss}] [%c] [%l]: %m");     mySuperDuperLogger.setLevel(Liquid_LogLevel.All);    mySuperDuperAppender.setFormat(mySuperDuperFormat);    mySuperDuperLogger.addAppender(mySuperDuperAppender);    logging = true;  }  else  {      logging = false;  } // The Liquid_Logging plugin exists we can log stuff!  if (logging) {   mySuperDuperLogger.info("An Info message");   mySuperDuperLogger.debug("A Debug message");  mySuperDuperLogger.warn("A Warning message"); mySuperDuperLogger.error("An error message with an exception!",someExceptionGoesHere); } 



    Using In events

    SpoilerTo use in event simply call the Plugin Command as follows:

    LiquidLog loglevelhere message goes here

    Examples:

    LiquidLog info Info Message HURRAY!

    LiquidLog debug DEBUG MESSAGE YES!

    LiquidLog warn A WARNING

    LiquidLog error AN ERROR!



    Demo
    Coming soon if you guys really want one.

    Script

    Save the script as Liquid_Logging.js in your plugins file. 

     Download: http://pastebin.com/GVZqZAfV

    FAQ
    Q: What are patterns?
    A: Patterns are what the PatternFormatter type of formatter uses to generate the logging message format. They're basically strings of variables to determine what goes where. An example is: [%c] [%l]: %m

        That pattern would log messages as "[Logger Name] [Logging Level]: Your logged message goes here."

    Q: How do we extend this as  afford mentioned?
    A: Create a new object for whatever you want to make a custom thing for (Appender or Formatter), and base that object off Liquid_LogAppender (for appenders) or Liquid_LogFormat (for formats).

        You can take a look at the Liquid_ConsoleAppender and Liquid_PatternFormatter for examples of this.

    Q: Any future plans to extend this?

    A: Sure I have some ideas, but if you have suggestions feel free to post!

    Credit and Terms of Use
    - Liquidize

    You are free to use and extend this as you will, credit isn't needed but is appreciated.

    Author's Notes
    I apologize if this is poorly written, I've only been using Javascript for a week, but think I've done pretty good since its similar to languages I am used too. I am working on refactoring the code and optimizing it, as well as reformatting the comments/commenting the methods. So please be paitent.


    本贴来自国际rpgmaker官方论坛作者:Kaliya处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/liquid-logging-utility.49172/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-7-10 02:59 , Processed in 0.090093 second(s), 54 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表