Glavin001 / atom-beautify

:mega: Help Wanted - Looking for Maintainer: https://github.com/Glavin001/atom-beautify/issues/2572 | :lipstick: Universal beautification package for Atom editor (:warning: Currently migrating to https://github.com/Unibeautify/ and have very limited bandwidth for Atom-Beautify Issues. Thank you for your patience and understanding :heart: )
http://unibeautify.com/
MIT License
1.5k stars 453 forks source link

Improve Logging #296

Closed Glavin001 closed 9 years ago

Glavin001 commented 9 years ago

TODO:

Glavin001 commented 9 years ago

Let's use https://github.com/winstonjs/winston

Glavin001 commented 9 years ago

The Console transport does not work...

Going to use the File transport and then create a Writeable Stream. See simplified Constructor API: http://stackoverflow.com/a/21583831/2578205

Glavin001 commented 9 years ago

Atom Beautify - Debugging information

The following debugging information was generated by Atom Beautify on Mon May 04 2015 02:08:50 GMT-0300 (ADT).


Platform: darwin

Versions

Atom Version: 0.196.0

Atom Beautify Version: 0.26.2

Original file to be beautified

Original File Path: /Users/glavin/Documents/Project Dev/atom-beautify/examples/simple-jsbeautifyrc/html-erb/original/_test.erb

Original File Grammar: HTML (Ruby - ERB)

Original File Contents:

<DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
            <title>Shopping List for <%= @date.strftime('%A, %d %B %Y') %></title>
        </head>
        <body>
                 <h1>Shopping List for <%= @date.strftime('%A, %d %B %Y') %></h1>
                <p>You need to buy:</p>
                <ul>
                  <% for @item in @items %>
                    <li><%= h(@item) %></li>
                  <% end %>
                </ul>
        </body>
        </html>

Beautification options

Editor Options: Options from Atom Editor settings

{
    "indent_size": 4,
    "indent_char": " ",
    "indent_with_tabs": false
}

Config Options: Options from Atom Beautify package settings

{
    "js": {
        "wrap_line_length": 80,
        "indent_size": 4,
        "indent_char": " ",
        "indent_level": 0,
        "indent_with_tabs": false,
        "preserve_newlines": true,
        "max_preserve_newlines": 10,
        "space_in_paren": false,
        "jslint_happy": false,
        "space_after_anon_function": false,
        "brace_style": "collapse",
        "break_chained_methods": false,
        "keep_array_indentation": false,
        "keep_function_indentation": false,
        "space_before_conditional": true,
        "eval_code": false,
        "unescape_strings": false,
        "end_with_newline": false
    },
    "css": {
        "preserve_newlines": true,
        "indent_size": 4,
        "indent_char": " ",
        "selector_separator_newline": false,
        "newline_between_rules": false
    },
    "cs": {
        "configPath": ""
    },
    "c": {
        "configPath": ""
    },
    "cpp": {
        "configPath": ""
    },
    "d": {
        "configPath": ""
    },
    "html": {
        "indent_inner_html": false,
        "indent_size": 4,
        "indent_char": " ",
        "brace_style": "collapse",
        "indent_scripts": "normal",
        "wrap_line_length": 250,
        "wrap_attributes": "auto",
        "wrap_attributes_indent_size": 4,
        "preserve_newlines": true,
        "max_preserve_newlines": 10,
        "unformatted": [
            "a",
            "sub",
            "sup",
            "b",
            "i",
            "u"
        ],
        "end_with_newline": false
    },
    "java": {
        "configPath": ""
    },
    "objectivec": {
        "configPath": ""
    },
    "pawn": {
        "configPath": ""
    },
    "perl": {
        "perltidy_profile": ""
    },
    "php": {
        "fixers": "",
        "level": ""
    },
    "python": {
        "max_line_length": 79,
        "indent_size": 4,
        "ignore": [
            "E24"
        ]
    },
    "sql": {
        "indent_size": 4,
        "keywords": "upper",
        "identifiers": "lower"
    },
    "vala": {
        "configPath": ""
    }
}

Home Options: Options from /Users/glavin/.jsbeautifyrc

{}

EditorConfig Options: Options from EditorConfig file

{
    "indent_style": "space",
    "indent_size": 2,
    "end_of_line": "lf",
    "charset": "utf-8",
    "trim_trailing_whitespace": true,
    "insert_final_newline": true,
    "tab_width": 2,
    "indent_char": " "
}

Project Options: Options from .jsbeautifyrc files starting from directory /Users/glavin/Documents/Project Dev/atom-beautify/examples/simple-jsbeautifyrc/html-erb/original and going up to root

[
    {},
    {},
    {
        "indent_size": 2,
        "indent_char": " ",
        "other": " ",
        "indent_level": 0,
        "indent_with_tabs": false,
        "preserve_newlines": true,
        "max_preserve_newlines": 2,
        "jslint_happy": true,
        "indent_handlebars": true,
        "object": {}
    },
    {},
    {
        "indent_size": 2,
        "indent_char": " ",
        "indent_level": 0,
        "indent_with_tabs": false,
        "preserve_newlines": true,
        "max_preserve_newlines": 2,
        "jslint_happy": true
    },
    {},
    {},
    {},
    {}
]

Results

Beautified File Contents:

/Users/glavin/.rvm/gems/ruby-1.9.3-p551/gems/htmlbeautifier-1.1.0/bin/htmlbeautifier:53:in `read': No such file or directory - < (Errno::ENOENT)
    from /Users/glavin/.rvm/gems/ruby-1.9.3-p551/gems/htmlbeautifier-1.1.0/bin/htmlbeautifier:53:in `block in <top (required)>'
    from /Users/glavin/.rvm/gems/ruby-1.9.3-p551/gems/htmlbeautifier-1.1.0/bin/htmlbeautifier:52:in `each'
    from /Users/glavin/.rvm/gems/ruby-1.9.3-p551/gems/htmlbeautifier-1.1.0/bin/htmlbeautifier:52:in `<top (required)>'
    from /Users/glavin/.rvm/gems/ruby-1.9.3-p551/bin/htmlbeautifier:23:in `load'
    from /Users/glavin/.rvm/gems/ruby-1.9.3-p551/bin/htmlbeautifier:23:in `<main>'
    from /Users/glavin/.rvm/gems/ruby-1.9.3-p551/bin/ruby_executable_hooks:15:in `eval'
    from /Users/glavin/.rvm/gems/ruby-1.9.3-p551/bin/ruby_executable_hooks:15:in `<main>'

Logs:

2015-05-04T05:08:50.338Z - info: [/Users/glavin/Documents/Project Dev/atom-beautify/src/beautifiers/index.coffee] beautify <DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
            <title>Shopping List for <%= @date.strftime('%A, %d %B %Y') %></title>
        </head>
        <body>
                 <h1>Shopping List for <%= @date.strftime('%A, %d %B %Y') %></h1>
                <p>You need to buy:</p>
                <ul>
                  <% for @item in @items %>
                    <li><%= h(@item) %></li>
                  <% end %>
                </ul>
        </body>
        </html>
 [ { indent_size: 4, indent_char: ' ', indent_with_tabs: false },
  { js: 
     { wrap_line_length: 80,
       indent_size: 4,
       indent_char: ' ',
       indent_level: 0,
       indent_with_tabs: false,
       preserve_newlines: true,
       max_preserve_newlines: 10,
       space_in_paren: false,
       jslint_happy: false,
       space_after_anon_function: false,
       brace_style: 'collapse',
       break_chained_methods: false,
       keep_array_indentation: false,
       keep_function_indentation: false,
       space_before_conditional: true,
       eval_code: false,
       unescape_strings: false,
       end_with_newline: false },
    css: 
     { preserve_newlines: true,
       indent_size: 4,
       indent_char: ' ',
       selector_separator_newline: false,
       newline_between_rules: false },
    cs: { configPath: '' },
    c: { configPath: '' },
    cpp: { configPath: '' },
    d: { configPath: '' },
    html: 
     { indent_inner_html: false,
       indent_size: 4,
       indent_char: ' ',
       brace_style: 'collapse',
       indent_scripts: 'normal',
       wrap_line_length: 250,
       wrap_attributes: 'auto',
       wrap_attributes_indent_size: 4,
       preserve_newlines: true,
       max_preserve_newlines: 10,
       unformatted: [Object],
       end_with_newline: false },
    java: { configPath: '' },
    objectivec: { configPath: '' },
    pawn: { configPath: '' },
    perl: { perltidy_profile: '' },
    php: { fixers: '', level: '' },
    python: { max_line_length: 79, indent_size: 4, ignore: [Object] },
    sql: { indent_size: 4, keywords: 'upper', identifiers: 'lower' },
    vala: { configPath: '' } },
  {},
  { indent_style: 'space',
    indent_size: 2,
    end_of_line: 'lf',
    charset: 'utf-8',
    trim_trailing_whitespace: true,
    insert_final_newline: true,
    tab_width: 2,
    indent_char: ' ' },
  {},
  {},
  { indent_size: 2,
    indent_char: ' ',
    other: ' ',
    indent_level: 0,
    indent_with_tabs: false,
    preserve_newlines: true,
    max_preserve_newlines: 2,
    jslint_happy: true,
    indent_handlebars: true,
    object: {} },
  {},
  { indent_size: 2,
    indent_char: ' ',
    indent_level: 0,
    indent_with_tabs: false,
    preserve_newlines: true,
    max_preserve_newlines: 2,
    jslint_happy: true },
  {},
  {},
  {},
  {} ] HTML (Ruby - ERB) /Users/glavin/Documents/Project Dev/atom-beautify/examples/simple-jsbeautifyrc/html-erb/original/_test.erb
2015-05-04T05:08:50.340Z - verbose: [/Users/glavin/Documents/Project Dev/atom-beautify/src/beautifiers/index.coffee] HTML (Ruby - ERB) name=ERB, namespace=erb, fallback=[html], grammars=[HTML (Ruby - ERB), HTML (Rails)], extensions=[], options=[], beautifiers=[HTML Beautifier, Pretty Diff, Pretty Diff, Pretty Diff, Pretty Diff]
2015-05-04T05:08:50.340Z - verbose: [/Users/glavin/Documents/Project Dev/atom-beautify/src/beautifiers/index.coffee] beautifier HTML Beautifier silly=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, debug=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, verbose=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, info=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, warn=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, error=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, onLogging=function (handler) {
        var subscription;
        subscription = emitter.on('logging', handler);
        return subscription;
      }, silly=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, debug=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, verbose=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, info=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, warn=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, error=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, onLogging=function (handler) {
        var subscription;
        subscription = emitter.on('logging', handler);
        return subscription;
      }, languages=[ERB], MANPATH=/Users/glavin/.nvm/v0.10.32/share/man:/usr/local/share/man:/usr/share/man:/opt/X11/share/man:/Applications/Xcode.app/Contents/Developer/usr/share/man:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man, NVM_IOJS_ORG_VERSION_LISTING=https://iojs.org/dist/index.tab, rvm_bin_path=/Users/glavin/.rvm/bin, VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh, VIRTUALENVWRAPPER_PROJECT_FILENAME=.project, GEM_HOME=/Users/glavin/.rvm/gems/ruby-1.9.3-p551, SHELL=/bin/bash, CLICOLOR=1, IRBRC=/Users/glavin/.rvm/rubies/ruby-1.9.3-p551/.irbrc, TMPDIR=/var/folders/lw/ct2vyvzs04gd_l8bn8794t800000gn/T/, NVM_PATH=/Users/glavin/.nvm/v0.10.32/lib/node, Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.sExKJP7PAX/Render, MY_RUBY_HOME=/Users/glavin/.rvm/rubies/ruby-1.9.3-p551, ATOM_HOME=/Users/glavin/.atom, NVM_DIR=/Users/glavin/.nvm, USER=glavin, _system_type=Darwin, rvm_path=/Users/glavin/.rvm, SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.xa85VdFsCs/Listeners, __CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0, WORKON_HOME=/Users/glavin/.virtualenvs, LSCOLORS=ExFxBxDxCxegedabagacad, rvm_prefix=/Users/glavin, VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python, GOOGLE_API_KEY=AIzaSyAQfxPJiounkhOjODEO5ZieffeBv6yft2Q, PATH=/Users/glavin/.rvm/gems/ruby-1.9.3-p551/bin:/Users/glavin/.rvm/gems/ruby-1.9.3-p551@global/bin:/Users/glavin/.rvm/rubies/ruby-1.9.3-p551/bin:/Users/glavin/.nvm/v0.10.32/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/texbin:/Developer/android-sdk-macosx/tools:/Developer/android-sdk-macosx/platform-tools:/Users/glavin/pear/bin:/Users/glavin/gocode/bin:/Users/glavin/.rvm/bin, VIRTUALENVWRAPPER_HOOK_DIR=/Users/glavin/.virtualenvs, NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist, PWD=/, EDITOR=vim, NODE_PATH=/Applications/Atom.app/Contents/Resources/app.asar/exports, _system_arch=x86_64, XPC_FLAGS=0x0, VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv, PS1=\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]$ , NODE_ENV=production, _system_version=10.10, XPC_SERVICE_NAME=0, rvm_version=1.26.10 (master), SHLVL=1, HOME=/Users/glavin, PYTHONPATH=/Users/glavin/Documents/Project Dev/ProjectIce:/usr/local/lib/python2.7/site-packages:, LOGNAME=glavin, GEM_PATH=/Users/glavin/.rvm/gems/ruby-1.9.3-p551:/Users/glavin/.rvm/gems/ruby-1.9.3-p551@global, GOPATH=/Users/glavin/gocode, NVM_BIN=/Users/glavin/.nvm/v0.10.32/bin, PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig, NVM_IOJS_ORG_MIRROR=https://iojs.org/dist, VIRTUALENVWRAPPER_WORKON_CD=1, DISPLAY=/private/tmp/com.apple.launchd.Jlnwk9oXLG/org.macosforge.xquartz:0, RUBY_VERSION=ruby-1.9.3-p551, _system_name=OSX, _=/usr/bin/env, _envCacheDate=Mon May 04 2015 02:06:49 GMT-0300 (ADT), silly=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, debug=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, verbose=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, info=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, warn=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, error=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, onLogging=function (handler) {
        var subscription;
        subscription = emitter.on('logging', handler);
        return subscription;
      }, silly=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, debug=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, verbose=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, info=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, warn=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, error=function (msg) {
      // build argument list (level, msg, ... [string interpolate], [{metadata}], [callback])
      var args = [level].concat(Array.prototype.slice.call(arguments));
      target.log.apply(target, args);
    }, onLogging=function (handler) {
        var subscription;
        subscription = emitter.on('logging', handler);
        return subscription;
      }, languages=[CSV, ERB, EJS, HTML, XML, Spacebars, JSX, JavaScript, CSS, SCSS, Sass, JSON, TSS, LESS]
2015-05-04T05:08:50.343Z - debug: [/Users/glavin/Documents/Project Dev/atom-beautify/src/beautifiers/beautifier.coffee] tempFile input null path=/var/folders/lw/ct2vyvzs04gd_l8bn8794t800000gn/T/input11544-55187-153w4tc, fd=41
2015-05-04T05:08:50.344Z - debug: [/Users/glavin/Documents/Project Dev/atom-beautify/src/beautifiers/beautifier.coffee] tempFile output null path=/var/folders/lw/ct2vyvzs04gd_l8bn8794t800000gn/T/output11544-55187-1pbl20j, fd=43
2015-05-04T05:08:51.531Z - debug: [/Users/glavin/Documents/Project Dev/atom-beautify/src/beautifiers/beautifier.coffee] spawn htmlbeautifier 0=<, 1=/var/folders/lw/ct2vyvzs04gd_l8bn8794t800000gn/T/input11544-55187-153w4tc, 2=>, 3=/var/folders/lw/ct2vyvzs04gd_l8bn8794t800000gn/T/output11544-55187-1pbl20j
2015-05-04T05:08:51.640Z - debug: [/Users/glavin/Documents/Project Dev/atom-beautify/src/beautifiers/beautifier.coffee] spawn done 1 /Users/glavin/.rvm/gems/ruby-1.9.3-p551/gems/htmlbeautifier-1.1.0/bin/htmlbeautifier:53:in `read': No such file or directory - < (Errno::ENOENT)
    from /Users/glavin/.rvm/gems/ruby-1.9.3-p551/gems/htmlbeautifier-1.1.0/bin/htmlbeautifier:53:in `block in <top (required)>'
    from /Users/glavin/.rvm/gems/ruby-1.9.3-p551/gems/htmlbeautifier-1.1.0/bin/htmlbeautifier:52:in `each'
    from /Users/glavin/.rvm/gems/ruby-1.9.3-p551/gems/htmlbeautifier-1.1.0/bin/htmlbeautifier:52:in `<top (required)>'
    from /Users/glavin/.rvm/gems/ruby-1.9.3-p551/bin/htmlbeautifier:23:in `load'
    from /Users/glavin/.rvm/gems/ruby-1.9.3-p551/bin/htmlbeautifier:23:in `<main>'
    from /Users/glavin/.rvm/gems/ruby-1.9.3-p551/bin/ruby_executable_hooks:15:in `eval'
    from /Users/glavin/.rvm/gems/ruby-1.9.3-p551/bin/ruby_executable_hooks:15:in `<main>'
Glavin001 commented 9 years ago

Published to v0.26.3