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

New syntax? #1

Open
muuvmuuv opened this issue May 3, 2019 · 1 comment
Open

New syntax? #1

muuvmuuv opened this issue May 3, 2019 · 1 comment

Comments

@muuvmuuv
Copy link

muuvmuuv commented May 3, 2019

Would be nice if Tiza would have a similar syntax as chalk. Atm Tiza must call .log to print the text to the console. This makes it really hard IMO to keep logs organized, especially when working with new template syntax ``. It would be great if log is not needed and I can do the following:

const status = tiza.red(event.status.toString())
const method = tiza.bold.green(logRequest.method.toUpperCase())
console.groupCollapsed(
  tiza.size(2)(`HTTPRequest (${method}) => ${status} :: ${requestUrl}`)
)

To make this possible a reset string could be added everytime after something is set e.g. tiza.red.

@muuvmuuv
Copy link
Author

muuvmuuv commented May 3, 2019

My solution ATM is:

const status = print(
  tiza.color('red').text(event.status.toString())
)
const method = logRequest.method.toUpperCase()
console.groupCollapsed(
  `HTTPRequest (${method}) => ${status.text} :: ${requestUrl}`,
  ...status.color
)

function  print(tizaObj: Tiza) {
    const reset = `
      color: inherit;
      font-size: inherit;
      font-weight: inherit;
      line-height: inherit;
      margin: inherit;
      padding: inherit;
      letter-spacing: inherit;
      font-family: inherit;
    `
    return {
      text:
        tizaObj
          .getTexts()
          .map(t => `%c${t}`)
          .join('') + '%c',
      color: [tizaObj.getStyles().join(';'), reset],
    }
 }

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

No branches or pull requests

1 participant