Skip to content
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

Add theming #19

Closed
wants to merge 2 commits into from
Closed

Add theming #19

wants to merge 2 commits into from

Conversation

sttk
Copy link
Contributor

@sttk sttk commented Dec 22, 2018

This pr enable to output themed logs by using theming-log. This will solve some issues about coloring of this module and gulp-cli.

This adds following four functions and one property:

  • log.themed(msg [, ...args])
  • log.info.themed(msg [, ...args])
  • log.warn.themed(msg [, ...args])
  • log.error.themed(msg [, ...args])
  • log.theme
log.theme.MSG = ansi.green
log.theme.INFO = ansi.blue
log.theme.ERROR = ansi.red
log.theme.WARN = ansi.yellow

log.themed('{MSG: This is a message. }')  // => Output the message in green.
log.info.themed('{INFO: This is a message. }')  // => Output the message in blue.
log.error.themed('{ERROR: This is a message. }')  // => Output the message in red.
log.warn.themed('{WARN: This is a message. }')  // => Output the message in yellow.

Also, this pr enable to customize timestamp color and format by innate properties in log.theme.

log.theme.TIMESTAMP.COLOR = ansi.magenta
log.themed('{MSG: This is a message. }')  // => Output the timestamp in magenta.

log.theme.TIMESTAMP.FORMAT = '({TIMESTAMP.COLOR: {NOW: YYYY/MM/DD HH:mm:ss}}) '
log.themed('{MSG: This is a message. }')  // => Output the timestamp like '(2018/12/22 18:53:21) '.

@sttk
Copy link
Contributor Author

sttk commented Dec 22, 2018

Moreover, I intend multilingualization of logging by this pr.

log.themed('{MSG: This is {1} of {2}.}', 'A', 'B')
// => [19:10:35] This is A of B.

log.themed('{MSG: これは{2}の{1}です。}', 'A', 'B')
// => [19:10:46] これはBのAです。

@sttk sttk changed the title Theming Add theming Dec 22, 2018
@phated
Copy link
Member

phated commented Dec 29, 2018

@sttk do we actually want to extend this module or should we just deprecate/archive this project and make a new module? I'm not sure if a better API can be written from scratch.

I kind of want to deprecate this once gulp 4.0 gets a stronger foothold so we can have people switch from fancy-log to gulplog - if we use fancy-log internally, we can't deprecate the package.

@phated
Copy link
Member

phated commented Dec 29, 2018

However, I do think you came up with a really elegant solution here!!

@sttk
Copy link
Contributor Author

sttk commented Dec 29, 2018

@phated I agree to unify gulp's logging function to gulplog, and I want to use theming-log's formatting in it. util.format is not enough because it's not parameter order free.

What I want for customization of logging is not only coloring but also message for multilingalization or as user's favorite with emoji. I believe that many people want them.

If it's ok, I'll add the same modification with this pr to gulplog. (Or replace debug/info/warn/error?)

@phated
Copy link
Member

phated commented Jan 2, 2019

@sttk instead of changing gulplog, why don't you just remove fancy-log in gulp-cli and use theming-log directly? Sorry, you've already done this as gulpjs/gulp-cli#161 - why do we need these changes if you've already done that?

We can make further changes to gulplog if we need to but I'd like to keep that very simple if possible.

@sttk
Copy link
Contributor Author

sttk commented Jan 4, 2019

@phated If fancy-log or gulplog will include theming-log, I'll change gulp-cli not to use theming-log directly.

I feel difficult to determine whether gulp-cli's logging function should assemble inside gulp-cli or outside. To assemble logging function into one module outside gulp-cli would make gulp-cli's code more simple.

@phated
Copy link
Member

phated commented Feb 25, 2019

@sttk I don't think fancy-log should have theming. I'm going to be deprecating it in favor of gulplog once we land everything into gulp-cli (and enough people are using gulp-cli so messages don't get swallowed).

@phated phated closed this Feb 25, 2019
@sttk
Copy link
Contributor Author

sttk commented Feb 25, 2019

@phated OK. I'll update gulpjs/gulp-cli#161 with new version of gulp-cli after fixing its some issues. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants