-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Building on postcss-log-warnings #1
Comments
Any plugin might use some "debug" or "info" type (or even "error" - for recoverable error (eg: postcss-custom-properties will use "error" when a undefined variable is referenced) |
|
why not. "log" was used to be clear that this plugin will display messages. |
|
Why not |
@ben-eb +1, I think that "log" word already means output to console |
because you can show messages into terminal (console) or in the css (via postcss-messages). |
I think we should have some coherence between postcss-messages & postcss-log-warnings.
|
I'm not sure if there is any benefit to separating this out into two modules. If they must be two modules then I think I would like to see |
@ben-eb console and browsers output are very different in my opinion. There are many options only for browsers output. Also terminal and browsers output is about different user cases. |
Those two modules does not share the same code I think (one append some css & the other output via console). That said, in the usage section of this module, we can see that the plugin that output into css might use it https://github.com/postcss/postcss-console-log-messages#usage I have some stuff to push in postcss-messages so I think I will make a PR with the use of this module. So what about
We can imagine to make a more abstract postcss-logger that doesn't do anything special without a function as an argument (runners might want to use this to display with their own methods (eg: Prepros app might want to use this)) |
@MoOx nice plan about common |
@ai That is true, but I am just thinking about how Sass works by default; it will both emit an error in the console and write some warning in the CSS file itself. This way it is absolutely clear to the user that something went wrong. @MoOx I like your second two ideas, |
@ben-eb do I remember correct, that Sass output only errors to CSS, not a warnings. |
@ai Yep, I think just errors, not warnings. |
-logger make more sense to me than log- Also for the we should have a postcss-logger that can consume reporter and return a string, that will be used by postcss-*-logger. postcss-log-* might make sense but postcss-log is not at all. So I prefer the logger thing |
Good point, I am OK with |
@MoOx 👍 |
I'm 👍 for |
These shorter names sound good to me. @lydell added the section to the readme about using Another Q: If there are different types of messages being displayed --- if the console-logger shows errors, warnings, and any other type of message from any other plugin --- then should we change the format in some way? Should we log them all together but include the message's type in the readout? Or log separate sections: all warnings together, all errors together, all other messages together, etc.? |
Maybe we should support reporter like lots of tool does ? |
@MoOx This would be pretty sweet.
|
I like the |
Let's keep the naming simple & clear; the main module can provide the user with customisation of what log levels he/she wants, and can simply be called Perhaps it should bundle |
Console & browser should be able to consume the reporters (which are just message formatters). Maybe formatter is a more accurate word. |
I'm happy with |
Ok, so what I was calling |
Yes; essentially we are abstracting the logic of what to show in one module, and how that is shown in a separate |
Hm. I'm still a little confused. Let's outline the proposed modules. Correct me if I'm wrong please:
Close? |
@davidtheclark You can see an example of this architecture in my css-minifier tests repo. |
It's more
- reporters (where): cli, browser, file...
- formatters: default, stylish (see jshint/eslint), tap...
|
I was confused by thinking that you two were using reporter/formatter interchangeably, or deciding between those two terms. I'm still confused, though: are you two in agreement or not? Because @ben-eb's |
I will do that when I will be on my computer. |
Yeah I think I may have got those mixed up. Here is another use case: https://www.npmjs.com/package/mocha-osx-reporter So we need some main module to let the user decide which message/warnings/errors to display, then reporter modules to consume those messages and output them in a specific environment, and then optionally formatters to customise that display. Although I feel that those formatters are most likely only relevant to |
So I am thinking about:
I think all formatter might add cli color, because most people will use the cli reporter. Then other reporter will be able to strip colors (using chalk or just https://www.npmjs.com/package/strip-ansi) to use the ouput. Note that I would like to get verbose name like postcss-*-messages-(reporter|formatter) to be clear about what it is reporting, but I guess @ai will yell because modules names are too long... :) |
👍 To the ideas in this issue. Good thing I never started my plans from davidtheclark/postcss-log-warnings#10 :) |
👍 to @MoOx's plan. But I think |
What about postcss-browser-style-messages-reporter ? Long but clear. |
I think it is clear enough that |
Thanks for writing out that list. Sorry but I'm still unclear about the relationship between "reporter" and "formatter" -- because in all of the examples given so far the module combines both parts that it seems you're proposing we split up: the module takes an object in, turns it into a legible string, then "reports" that string in one way or another. What, for example, would the output look like for |
That the formatter job. All reporters will need to choose & use a default formatter. See http://eslint.org/docs/user-guide/command-line-interface#f-format |
The reporter should not turn something into a legible string - it simply consumes the PostCSS messages and emits events to its formatter, which returns a formatted string (in the case of postcss-cli-reporter), or some CSS styles (in the case of postcss-browser-reporter) which is then output accordingly. |
Ok. So I will not have a lot of time for a week or two but would like to take on the cli-reporter and stylish-formatter, if that's alright with everyone. |
Exactly. 😃 |
So here is what I think we should do to go forward without making 10 packages:
Then after that we might want to :
And maybe we can also do:
I would like to see If you find "messages-reporter" too long, maybe using "logger" seems a better idea, but I don't really like it anymore :) I have some wip on that for cssnext I really want to push to communicate with cssnext users so I can probably handle some changes if @davidtheclark and @gazay are open too. Please let me know :) |
@MoOx IMO, the purpose of this module is to be a singular source of displaying errors/warnings/messages from other PostCSS modules. So in this case, someone would write The rest looks great. 👍 |
Ok so I guess others will say the same. |
Sounds good. |
Sounds like davidtheclark/postcss-log-warnings#10. |
It does. I think the main changes from the log-warnings codebase would be:
I also would like to improve the organization of the tests and do some integration tests in addition to the unit tests that mock postcss results. |
@lydell I've had a couple of minutes to work on this and I thought of two possible changes that would affect that plan of using this as an library. I was thinking that maybe the division-of-labor would make more sense if the reporter were responsible for determining which messages get logged (reporter has the What do you think? Any other @postcss/owners have opinions? |
I totally agree |
@MoOx @davidtheclark Yep, agreed. This is how tape works; it always outputs an unformatted standard output. It is up to formatters to make that look pretty (or do something else with it). 😄 |
I just published v0.1.0. Feedback welcome! |
@postcss/owners I've made some minor preliminary alterations to adapt
postcss-log-warnings
to this new name. Also, I changed thekeepWarnings
option to its reverse,clearWarnings
, since people seemed to want that.(For reference: the discussion for moving this was at postcss/postcss-browser-reporter#17)
I could try to rewrite names and docs so that they're discussing "messages" more generically, rather than "warnings", specifically; but that might be kind of confusing since there are no other types of messages to give examples of, right? (Except errors, which this plugin is ignoring currently --- should it log them?)
Thoughts?
The text was updated successfully, but these errors were encountered: