babakfp
babakfp11mo ago

How can I use "Logging with colors" with `"npm:log-update"`

Hi https://examples.deno.land/color-logging I don't want to use Chalk because it's not properly typed.
Logging with colors - Deno by Example
Most modern terminals can display program logs in colors and with text decorations. This example shows how to display colors when using console.log. -- Deno by example is a collection of annotated examples for how to use Deno, and the various features it provides.
2 Replies
babakfp
babakfp11mo ago
If there is another library that I can use instead of log-update that works with "Logging with colors", I would like to try it out. https://deno.land/std@0.123.0/fmt/colors.ts
Deno AI Helper
Deno AI Helper11mo ago
The documentation provides examples of how to use color logging in Deno. However, it does not provide specific information on how to use color logging with the npm:log-update package. Here's how you can use color logging in Deno based on the documentation:
console.log("%cHello World", "color: red");
console.log("%cHello World", "background-color: blue");
console.log("%cHello World", "text-decoration: underline");
console.log("%cHello World", "text-decoration: line-through");
console.log("%cHello World", "font-weight: bold");
console.log("%cHello %cWorld", "color: red", "color: blue");
console.log("%cHello World", "color: #FFC0CB");
console.log("%cHello World", "color: rgb(255, 192, 203)");
console.log("%cHello World", "color: red");
console.log("%cHello World", "background-color: blue");
console.log("%cHello World", "text-decoration: underline");
console.log("%cHello World", "text-decoration: line-through");
console.log("%cHello World", "font-weight: bold");
console.log("%cHello %cWorld", "color: red", "color: blue");
console.log("%cHello World", "color: #FFC0CB");
console.log("%cHello World", "color: rgb(255, 192, 203)");
In these examples, the %c syntax is used in console.log to apply CSS styles to the output text. The styles are specified as the second argument to console.log. However, to use this with npm:log-update, you would need to import the log-update package from npm and use it in your Deno application. The documentation does not provide a clear answer on how to do this. You might want to check the log-update package documentation or source code to see if it supports CSS styling in a similar way to console.log. If it does, you should be able to use the same %c syntax to apply colors and other styles. If it doesn't, you might need to find a different way to apply colors when using log-update.