vishysank / console-log-atom

A console.log generator for atom editor
MIT License
21 stars 2 forks source link

Pre-configured logging prefix #16

Open johnrix opened 8 years ago

johnrix commented 8 years ago

Would be useful to have an option to set a logging prefix to use on all console log messages generated. This could then be used to quickly filter the log output in the console accordingly.

vishysank commented 8 years ago

@johnrix good point, if you take a look at the code that is here, it should be pretty easy to add this. If you want to take a stab at this and submit a PR that would be great !

pdonias commented 7 years ago

Would the prefix be added even if no text was selected?

vishysank commented 7 years ago

@pdonias, yes i was thinking that i would remove the whole 'TEST' prefix config option if no text was selected, adn have a new option (logging prefix). That way if a user selects this option, they must define a logging prefix, and it is used for all console log functions. I would also like to have a part of this prefix be the line number, so that if a person just has a bunch of console log statements in different parts of the code, instead of just saying something like "console.log('PREFIX')", it could say something like "console.log('PREFIX LINE 40')" making it easier to identify.

pdonias commented 7 years ago

Sounds great :)

vishysank commented 7 years ago

@pdonias, were you planning on taking a shot at this ? i got started a little while back, but am going to be bogged down with some of my job responsibilities till the ned of the year, so wont be able to get to this anytime soon. Also, thanks so much for cleaning up some of the other issues for the package ?

pdonias commented 7 years ago

I wasn't planning to do it right now but maybe later, I don't know. But I'll make sure to let you know if I'm working on it (by assigning myself on the issue, for example) so we don't do the same job twice.

vishysank commented 7 years ago

perfect thanks.

johnrix commented 7 years ago

Hi guys, apologies I didn't respond previously. I did clone the repo and start looking at it, but like yourself, got bogged down in work commitments. First time looking at Coffeescript or Atom extensions also, which slowed me up.

I do have another suggestion for improvement though, which is to have configurable log statements to support different languages besides Javascript, as well as custom log commands. I use PHP a good bit and have my own custom log command for the application I work on. It would be so handy to have this work for that also.

Perhaps a logging command template that applies per file extension? Maybe should be logged as a separate issue though?

vishysank commented 7 years ago

@johnrix good idea, i think there is an issue already for this https://github.com/vishysank/console-log-atom/issues/5. I dont really use php, but do you have a sense of the log commands that you use ? Maybe if you can document them in an issue to enable php support, someone can pick it up to add that functionality

johnrix commented 7 years ago

I've used various logging commands for PHP over the years, some being roll-your-own tools, other third party tools and also some PHP built-in commands, all depending upon the use case. Most recently, I wrapped one of my own in a global function named 'consolelog' with the same argument signature as the javascript console.log() function, so I can use your plugin and just remove the '.' before saving (PHP's object method/property access syntax uses arrows (->) instead of dots, so 'console.log' isn't feasible).

It would be handy to simply have a template field per file extension, where you can insert placeholders for the variable to log and the associated label eg.

myDebugClass->debug(%var, %label); 
somedebugthing %var
etc.