Console Trace - Create an Error Log

Discussion in 'JS Plugin Releases (RMMV)' started by Zalerinian, Jan 22, 2018.

  1. Zalerinian

    Zalerinian Jack of all Errors Veteran

    Messages:
    4,695
    Likes Received:
    921
    Location:
    The Internet.
    First Language:
    English
    Primarily Uses:
    N/A
    Console Trace 1.0.0 ~ Zalerinian

    Introduction
    Getting error information from players sometimes seems harder than pulling teeth, but it doesn't have to! ConsoleTrace is a small, light-weight utility that will write a log of console output to a file to create a log for deployed games. Instead of giving players access to the powerful developer console and trying to guide them through it, you can have them send you a file - a process most people are used to!

    Features
    ConsoleTrace works completely in the background once you configure it (and it works out of the box, too!). Simply set the types of messages you'd like to save, the file you want it to write to, and whether or not the log should be cleared at the launch of the game, and you're all set to go!

    Screenshots
    An error message seen in the console vs seen in the generated log file.
    [​IMG]

    How to Use
    The plugin can be installed and used right away! Place it in your plugins folder, and add it through the plugin manager. Changing options is purely optional, but you may want to change the log level to include more information for extended debugging purposes.

    Download
    The script is available from github. Right click and select "Save file as..." (or your browser equivalent) on the "Raw" button to download the file directly, or just copy all the code and place it in a file in your plugins directory. The plugin will find its parameters regardless of filename.

    FAQ
    Q: Can I use this in my commercial project?
    A: ConsoleTrace is licensed under the MIT license, which allows use for commercial and non-commercial projects, as long as credit is provided.

    Q: I can't find my logs!
    A: What version of MV are you using? 1.5.1 and below place the log in the same folder as Game.exe, so if you're playtesting, this is where MV is installed, in the nwjs-platform folder, where platform is what operating system you use.

    If you're using 1.6.0 or above, the logs should be placed in the same folder as your Game.rpgproject file, and all the data to your plugin, which is easier to find.

    Q: I have an idea for something to add to ConsoleTrace.
    A: I'm open to receiving feedback and new ideas on my plugins. Please PM me on the forums with your idea.

    Credit and Thanks
    - Zalerinian

    Author's Notes
    ConsoleTrace is a very light plugin. It uses asynchronous calls to write data to the log file, and uses a queue system that prevents it from making excessive allocation. There should be very little to no affect on performance by using this plugin.

    Also, please note that logs will not appear correctly when viewed through the standard Notepad program in windows. Please view files in NotePad++, Sublime Text, Atom, Visual Studio Code, or basically any other text editor ever made.
     
    Last edited: Jan 22, 2018
    #1
  2. Jonforum

    Jonforum Veteran Veteran

    Messages:
    1,574
    Likes Received:
    1,342
    Location:
    Canada / Québec
    First Language:
    French
    Primarily Uses:
    RMMV
    very useful, especially that the copy past are poor and bad on the console debug.
    however, I wonder if this feature is not already native in node with these arguments in the package.json
    PHP:
     "chromium-args" " --enable-logging --v=1",
    // or
    nw --enable-logging --v=1
    i never give a try, but thank.
    source:http://www.chromium.org/for-testers/enable-logging
     
    #2
  3. Shaz

    Shaz Veteran Veteran

    Messages:
    37,339
    Likes Received:
    11,141
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Getting error information from some game developers can sometimes seem harder than pulling teeth too!

    Nice job - I always like the developer tools :)
     
    #3
    Llareian likes this.
  4. Zalerinian

    Zalerinian Jack of all Errors Veteran

    Messages:
    4,695
    Likes Received:
    921
    Location:
    The Internet.
    First Language:
    English
    Primarily Uses:
    N/A
    I wasn't aware of this, but doing a quick test on a small, deployed game, I couldn't find any log generated by these command line arguments. If you know where the log would be saved, let me know and I'll take another look, but so far, I at least know where the logs generated by the plugin will be :p

    Oh, and I forgot to mention, but it is confirmed working for 1.6.0. In 1.6.0, the log will be in the project's folder, where the .rpgproject file is. In 1.5.1 and below, the log was placed where the NWJS executable one, such as the steam directory. Given that 1.6.0 is pending release shortly, and that this is a non-issue on publicly deployed games, I don't believe it's worth "fixing", especially since someone could go to the proper path when directed to find the log.
     
    #4
    Jonforum likes this.
  5. Jonforum

    Jonforum Veteran Veteran

    Messages:
    1,574
    Likes Received:
    1,342
    Location:
    Canada / Québec
    First Language:
    French
    Primarily Uses:
    RMMV
    hum this its a good question !
    logicly
    • [Profile Path] C:\Users\Alice\AppData\Local\Google\Chrome\User Data\Default
    • [User Data Dir] C:\Users\Alice\AppData\Local\Google\Chrome\User Data
    but with node project from rmmv dir, i don't know, maybe it not work because it a very very old version of nwjs.js
    maybe in the v1.6 arg will work ?
    i can not make a test , i dont no have steam .

    take l look in source here, it tell you all way to get the output log from this arg, also for ios and android
    https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md

    ps: tell me if you find why or something good.
    edit: it seem you can also add a dir in arg :
    did you try ?
    --user-data-dir=c:\foo
     
    Last edited: Jan 23, 2018
    #5
  6. Jonforum

    Jonforum Veteran Veteran

    Messages:
    1,574
    Likes Received:
    1,342
    Location:
    Canada / Québec
    First Language:
    French
    Primarily Uses:
    RMMV
    did you make a try with this in 1.5 or 1.6 "--user-data-dir=c:\foo --enable-logging --v=1"
    PHP:
    {
        
    "name""KADOKAWA/RPGMV",
        
    "main""www/index.html",
        
    "js-flags""--expose-gc",


        
    "chromium-args" "--user-data-dir=c:\foo --enable-logging --v=1",


        
    "window": {
            
    "title""",
            
    "toolbar"false,
            
    "width"816,
            
    "height"624,
            
    "icon""www/icon/icon.png"
        
    }
     
    }
    or
    PHP:
      "chromium-args" "--user-data-dir=c:\foo --enable-logging=filename --v=1",
    from
    C:\ [user] \Program Files (x86)\KADOKAWA\RPGMV\nwjs-win\package.json
     
    Last edited: Jan 23, 2018
    #6
  7. Zalerinian

    Zalerinian Jack of all Errors Veteran

    Messages:
    4,695
    Likes Received:
    921
    Location:
    The Internet.
    First Language:
    English
    Primarily Uses:
    N/A
    PHP:
    {
        
    "name""KADOKAWA/RPGMV",
        
    "main""www/index.html",
        
    "js-flags""--expose-gc",
        
    "chromium-flags""--user-data-dir=c:\\nwjs --enable-logging --v=1",
        
    "window": {
            
    "title""",
            
    "toolbar"true,
            
    "width"816,
            
    "height"624,
            
    "icon""www/icon/icon.png"
        
    }
    }
    I tried this with both chromium-args and chromium-flags, and I did find a log file that was autogenerated, however it did not provide the same information that is provided by this plugin (This is being tested on 1.5.1). The chromium logging is logging event within chrome, not within JavaScript. Things like extension loading/unloading, webGL context creation/destruction information for extensions to the browser, and that sort of thing. ConsoleTrace tracks specifically calls to console.log, console.info, console.warn, console.debug, and console.error (depending on the logging level set).

    One thing I'd really like to look into adding in the future is having it log resources that fail to load (these are not currently logged because they don't print their messages via console.error), as that would be a very good thing to have a log of.
     
    #7
    Jonforum likes this.
  8. Jonforum

    Jonforum Veteran Veteran

    Messages:
    1,574
    Likes Received:
    1,342
    Location:
    Canada / Québec
    First Language:
    French
    Primarily Uses:
    RMMV
    this its just a feature suggest for your plugin.
    If my memory it good, is possible to inject in the memory of the OS [clipboard], a formatted DATA string.
    maybe this can be fun
    *add auto copy [ctrl-c] data string on error , only need to do a ctrl+V after a error, where you want.

    PHP:
    var formated_DataString_Log String(dataLog);
    require(
    'nw.gui').Clipboard.get().setformated_DataString_Log ); // this will send DataLog error to clipboard OS memory
    it's an idea like this, for the super lazy dev like me lol :)
    maybe allow to set true or false for auto-clipboard on error log inside plugin option.

    the problem and the challenge will be how to format string correctly for easy paste log inside forum or VSC.
     
    Last edited: Jan 23, 2018
    #8
  9. Zalerinian

    Zalerinian Jack of all Errors Veteran

    Messages:
    4,695
    Likes Received:
    921
    Location:
    The Internet.
    First Language:
    English
    Primarily Uses:
    N/A
    That could be done, yeah. Do you mean for it to copy the last error when the game crashes, and displays a message (such as "cannot read property 'x' of undefined"), or what? Because that should be easy, but if you mean to have it copy the whole log... well that'll get messy.

    But I can definitely look into having it copy to the clipboard. One thing I've considered is automatic log upload on fatal error, but that would require developers to have a webserver and backend to receive and store these logs.

    What I can probably do for the clipboard is, if not automatic (because I feel like some users may find that to be invasive/annoying if they were keeping something important in their clipboard), I can add a button to the crash scene like MV does now with failing to load a resource.
     
    #9
  10. Jonforum

    Jonforum Veteran Veteran

    Messages:
    1,574
    Likes Received:
    1,342
    Location:
    Canada / Québec
    First Language:
    French
    Primarily Uses:
    RMMV
    yes I'm talking about the latest error log or the lots.
    it was just an idea to push the plugin even further.
    especially for the lazy-dev, I find sometimes annoying to select text and ctrl + c :popcorn::troll:
    can also be pre-formatted with the BBcode of the forum !.
     
    #10

Share This Page