Closed donquixote closed 3 years ago
Hey sir! And thanks
First of all great point! We should not let such noise to be!
First of all the whole DEBUG and the other tweaking environment variables are for debugging purpose! And that use the debug as you already know and pointed (repo)!
The normal usage is to not set them! I logged > "!!!!! ----- No debug env var ----- !!!!"
! I don't even remember why i left it as it is! It's better to not log it! And to add a section about debugging in the doc!
Mainly the debug environment variable are to be set! At the laravel-mix launching script! And that should be in package.json! As per this:
"hot": "cross-env NODE_ENV=development DEBUG=MixGlob,MixGlob:* node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
You can see it in the test example here!
One too can set them as you did! on the top level of the script! before requiring laravel-mix-glob! With process.env
! And because we are talking about debugging! it should be ok! It need too to be before require()
! So it works on the immediately invoked method!
I'm using debug package too for logging! DEBUG should not be set to false! unless! we don't want any logging from laravel-mix-glob!
Also DEBUG variable is necessary! the rest are variables that add more tweaking! I'll change the condition to check for DEBUG only! As that's is more right and effective!
I'll rework the whole thing to be clean and clearer!
Default is to not set them! And let the defaulting be handled by the script! Which will remove the debug mode! And leave logging and errors!
Then if somehow we want to disable some or to debug! We set DEBUG=MixGlob
or DEBUG=*
! Depending on what you want to cancel from the 3 options:
{
log: debug('MixGlob'),
err: debug('MixGlob:Error'),
debug: debug('MixGlob:debug')
}
We can cancel one as per the example: DEBUG=MixGlob, -MixGlob:debug
! That's the default! however! Removing errors while debug doesn't make sense! So in short! If one need to debug he can set DEBUG=*
or DEBUG=MixGlob
(The first will activate all logging to any used library that use debug package itself! Can be useful sometimes). If one need to just tweak the logging of DEBUG! He can use the other variables! I'll add a check to make it ok to just set the other variables without DEBUG! And that to just tweak the logging! We can too introduce our own environment variables that play the role of aliases! To make it more verbose and clear for logging only!
I like how you are just pointing the things by questions! And no! noise should not be! I wonder what's the noise that is going! As except for the first env block! For the rest no debugging logs should go! But only normal logging and errors! However! the logging wasn't finished completely right! I'll have a look at it by tomorrow! And i'll have it fixed! By the next two days!
Same go for the next following questions! Not enough to just set one! But i'll make it so! And the whole need to be documented i'll add a section!
Thank you for pointing all out! I'll go this way about it! Make DEBUG=1 (and true) possible and (process.env.DEBUG = true) (more simple)! Then normal debug usage! Alias for Logging tweaking (the other variables)! Remove the noise! And add a section about it in the doc! (Also the logging should be improved!)! I'll have done by this next 3 days! I'll put some time!
I'm looking too for collaborators and every help that the package can get! I'd love to add you as one if you'd like! That way the package can benefit from more! And get improved to meet higher quality! Including improving the doc and adding tests!
A question !? You related this to the other issue! There is only the problem of logs! Which is a clear thing! am i wrong ? Is there more ?
Hi, thanks for the quiick response. You surely love the "!" (exclamation mark) character :)
Also DEBUG variable is necessary! the rest are variables that add more tweaking! I'll change the condition to check for DEBUG only! As that's is more right and effective!
Why should it be necessary? And by necessary do you mean you would still show a debug message in this case? I think the "!!!!! ----- No debug env var ----- !!!!" should not be shown in any case.
Hi again, (and yea for !) !! hhh I'm just about to make the changes! Didn't get time till now!
You got me wrong! "!!!!! ----- No debug env var ----- !!!!" should not be shown! All should be clean! And DEBUG env var! Should only be used for debugging!
For necessary i was describing how the module debug works! To run the debug module logs! You have to set DEBUG
env var to something that activate the logs! For the other Flags (env vars) they are not necessary! But just tweaking elements!
For ex: if i set DEBUG_HIDE_DATE
without DEBUG
nothing will happen! And that's what i meant by necessary! Otherwise the point is clear! The noise should not be there! And i'm about to fix it now! I'll push a new version after finishing.
Fixed by aac47eb
You can check by updating to latest!
A section is added to the documentation (accessible here):
Laravel-mix-glob use debug module for it's logging! With MixGlob
domaine for log. And MixGlob:error
domaine for error. And MixGlob:debug
domaine for debug.
To activate debugging logs, you have to set the env var DEBUG
to "true"
or "1"
. And that's the simplest way!
Otherwise you can set DEBUG
to anything you want! Following debug module syntax!
ex: DEBUG=*
One may need to do that if he to see the logs of all packages that are working with debug module. However if DEBUG=1
or DEBUG=true
were used! Only MixGlob logging will run. And that's the simplest form! You don't even need to know about the debug module.
Where to set the env variable for debugging ?
You can set the env var either at the script launch. And that would be on package.json developement
script!
Or because it's just debugging! One can simply add this in webpack.mix.js
before requiring laravel-mix-glob
process.env.DEBUG=true; // 1 works too
const MixGlob = require('laravel-mix-glob');
There is some tweaks for the logging format! Those logging tweaks are described by this from debug doc (here):
Name | Purpose |
---|---|
DEBUG_HIDE_DATE |
Hide date from debug output (non-TTY). |
DEBUG_COLORS |
Whether or not to use colors in the debug output. |
DEBUG_DEPTH |
Object inspection depth. |
DEBUG_SHOW_HIDDEN |
Shows hidden properties on inspected objects. |
Better aliases are available:
Name | Purpose |
---|---|
LOG_HIDE_DATE |
Hide date from debug output (non-TTY). |
LOG_COLORS |
Whether or not to use colors in the debug output. |
LOG_DEPTH |
Object inspection depth. |
LOG_SHOW_HIDDEN |
Shows hidden properties on inspected objects. |
Hi! (I found #5, but I want to open a new issue with more specific title + description.)
laravel-mix-glob makes noise in the debug output, if none of the
process.env.DEBUG*
keys are present.Test scenario
The problem can be reduced to the following webpack.min.js:
-> "!!!!! ----- No debug env var ----- !!!!"
-> no warnings
Investigation
The code in
noDebugEnvVar()
suggests that we need at least one of the following keys inprocess.env
: The variables are explained on https://github.com/visionmedia/debug, and the same variables are also used in DEBUG_ENV_VARS in laravelMixGlob.min.js.DEBUG
DEBUG_HIDE_DATE
DEBUG_COLORS
DEBUG_DEPTH
DEBUG_SHOW_HIDDEN
Questions
This leads me to the following questions:
process.env.DEBUG*
?