GithubHelp home page GithubHelp logo

adamschwartz / log Goto Github PK

View Code? Open in Web Editor NEW
3.0K 66.0 138.0 77 KB

Console.log with style.

Home Page: https://adamschwartz.co/log

License: MIT License

CoffeeScript 10.85% JavaScript 11.19% HTML 41.89% CSS 36.07%
log devtools console js

log's Issues

Fallback for unsupported browsers

Doesn't come up with anything in unsupported browsers.

Perhaps still allowing non-formatted versions of the errors to still be shown. Some sort of graceful degradation maybe.

[enhancement] Add missing bower.json.

Hey, maintainer(s) of adamschwartz/log!

We at VersionEye are working hard to keep up the quality of the bower's registry.

We just finished our initial analysis of the quality of the Bower.io registry:

7530 - registered packages, 224 of them doesnt exists anymore;

We analysed 7306 existing packages and 1070 of them don't have bower.json on the master branch ( that's where a Bower client pulls a data ).

Sadly, your library adamschwartz/log is one of them.

Can you spare 15 minutes to help us to make Bower better?

Just add a new file bower.json and change attributes.

{
  "name": "adamschwartz/log",
  "version": "1.0.0",
  "main": "path/to/main.css",
  "description": "please add it",
  "license": "Eclipse",
  "ignore": [
    ".jshintrc",
    "**/*.txt"
  ],
  "dependencies": {
    "<dependency_name>": "<semantic_version>",
    "<dependency_name>": "<Local_folder>",
    "<dependency_name>": "<package>"
  },
  "devDependencies": {
    "<test-framework-name>": "<version>"
  }
}

Read more about bower.json on the official spefication and nodejs semver library has great examples of proper versioning.

NB! Please validate your bower.json with jsonlint before commiting your updates.

Thank you!

Timo,
twitter: @versioneye
email: [email protected]
VersionEye - no more legacy software!

Enable for the Safari Web Inspector in the WebKit Nightly

The Safari Web Inspector in today's WebKit Nightly now supports "%c" in format strings. http://nightly.webkit.org (r148526 or later). This also works when remotely inspecting iOS devices. Screenshot:

Screen Shot 2013-04-16 at 9 30 19 PM

Currently log.js disables support for Safari. It would be great if this was enabled for WebKit Nighty users using the Safari Web Inspector right now.

A common way to detect a WebKit Nightly user is to check for a + in WebKit number in the UserAgent, e.g. AppleWebKit/537.38+.

Safari 6.0.4:

// js> navigator.userAgent
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/536.29.13 (KHTML, like Gecko) Version/6.0.4 Safari/536.29.13"

WebKit Nightly:

// js> navigator.userAgent
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.38+ (KHTML, like Gecko) Version/6.0.4 Safari/536.29.13"

Bower Installation

It would be great if you allowed to install/update using bower.

Thanks!

Wrong processing (), [] in log string

Tested in Chrome 27.0.1453.12 dev, Firefox 19.0.2

log( "*(data)*")

Result: (data)
Expected: (data)


log("_(data)_")

Result: (data)
Expected: (data)


log('[c="color: red"](data)[c]')

Result: c='color: red'[c]
Expected: (data) in red color


log("*[data]*")

Result: [data]
OK


log("_[data]_")

Result: [data]
OK


log('[c="color: red"][data][c]')

Result: [c='color: red'][data][c]
Expected: [data] in red color

If at all possible, I would really appreciate having the file / Line # of invocation included

First off, Adam this is a brilliant piece of kit. Kudos.

I'm putting together a pack of Javascript libraries for Salesforce developers and would really love to include your library. One hitch, however, is the automatic inclusion of the file / line # of the invocation. I suspect that we'll always see log.js:19 on the right, but perhaps the file / line # of the invoking script can be included as a "tag" or something on the left ?

Set color via single quotes

log("this is [c='color: red']red[c]")
# for easy debugging with coffee
log "this is [c='color: red']#{someVariable}[c]"

Undefined in requirejs

main.js

  //the require library is configuring paths
  require.config({
    baseUrl: "../assets",
    paths: {
      //tries to load jQuery from Google's CDN first and falls back
      //to load locally
      log: ['log/log'],
      ractive: ['//cdn.ractivejs.org/latest/ractive'],
      rv: ["rv/rv"],

      jquery: ['//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min', 'jquery/jquery'],
      bootstrap: ['//netdna.bootstrapcdn.com/bootstrap/3.3.3/js/bootstrap.min', 'bootstrap/bootstrap'],
      moment: ['moment/moment']
    },
    shim: {
      'bootstrap': {
        deps: ['jquery']
      }
    },
    //how long the it tries to load a script before giving up, the default is 7
    waitSeconds: 10
  });
//requiring the scripts in the first argument and then passing the library namespaces into a callback
//you should be able to console log all of the callback arguments
  require(['jquery', 'moment', 'log', 'ractive', 'rv'],
    function ($, moment, log,Ractive, rv)
    {
      console.log(arguments, window.log);
      log("Log by log");
    });
})(require);

bower.json

{

  "private": true,
  "ignore": [
    "**/.*",
    "node_modules",
    "app/assets",
    "bower_components",
    "test",
    "tests"
  ],
  "dependencies": {
    "bootstrap": "~3.3.4",
    "jquery": "~2.1.3",
    "fontawesome": "~4.3.0",
    "moment": "~2.9.0",
    "requirejs": "~2.1.16",
    "rv": "~0.1.8",
    "log": "~0.1.5"
  }
}

.bowerrc

{
    "directory": "app/assets"
}

Colorize an object

Hello,

How it's possible to colorize an object's log ?
I've try
console.log($scope.myObject);
to
log('[c="color: #32c5d2"]' + $scope.myObject + '[c]');
The line is colorize but I can't click on the object for inspecting the properties

Embedded styles don't work

If you have styles within styles it doesn't render properly.

eg. log('_[c="color:red"]ERROR[c]_') doesn't make the font bold and red as expected. Also doesn't work if you swap the order.

Workaround, log('[c="color:red;font-weight:bold"]ERROR[c]')

npm version isn't up to date

Hello Adam !
I didn't know what would be the best place to submit this update request ...

May I ask you why NPM version available isn't the latest ?
Following workaround works fine though : npm install -S https://github.com/adamschwartz/log
The latest NPM version (0.1.5) makes it unusable with Webpack, since it needs following bit of code which is present in v0.3.0

  if (typeof define === 'function' && define.amd) {
    define(function() {
      return exportedLog;
    });

Anyway thanks for your work !
Mat

Does not work in Firefox

Firefox 20.0.1

Web Console: getting error message: The Web Console logging API (console.log, console.info, console.warn, console.error) has been disabled by a script on this page.
Firebug:
1

Multiline 'code' blocks?

Thinking the only difference is that in your regex we should allow for multiline?

It seems that log('this is a test') matches code for test but
log('this is a function () { hello; })

Improve custom style syntax

Do you think that something like log('this is <style="color: red">red</style>') makes the API syntax more specific? I think particularly in terms of beginners and consistency with HTML.

Best regards,
Rick

Offer a way to include the library into an arbitrary namespace

Hi Adam, I found your library whilst searching for source code to improve my understanding of regular expressions and console helper libraries.

I am very new to open source, but wondered if you think it would be a useful improvement to add a noConflict() method to the library (e.g. well known example in underscore.js). At least to me, it would seem that 'log' as a global object has the potential to conflict with other global variables given how close semantically it is to programming terminology in general. There are a lot of use cases for the word log!

Your documentation mentions that the syntax follows markdown styling, but that doesn't match what I found here: [(https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)]

Do you think there would be any benefit in getting these two to match? I would appreciate the opportunity to have a go at adding these features if you agree with my thinking. I would be happy to submit tests for the new code.

Regards,
Rick

Add broarder Markdown support

Your documentation mentions that the syntax follows markdown styling, but that doesn't match what I found here: [(https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)]

Do you think there would be any benefit in getting these two to match?

Best,
Rick

Console.log Backtrace

I think it would be neat if the Log provided details of the original SCRIPT

javascript_console

I generally tend to use the console as a Debugging Tool, for reading value data and so fourth.

But with the Log.js all console events, originate from log.js:line regardless of the originating script.

Clear the console, with style

The Chrome console (maybe other consoles?) can be cleared with clear(). Typing just clear is clearer (no pun intended) and classier. Just one line:

window.__defineGetter__('clear', function () { clear(); });

UA check is wrong.

In Safari, the page thought I was in Chrome, and in Chrome the page thought I was in Safari. Firefox and Opera seem to be fine. I'm running OS X 10.8.2, Safari 6.0.2, Chrome 26.0.1410.65, and Chrome Canary 28.0.1466.0 canary.

PR: Table Log

Willing to make a PR for a feature similar to console.table(). Would this pr be welcome?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.