Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/uzmoi/log-styling
Tiny utility for formatting console output with CSS.
https://github.com/uzmoi/log-styling
console console-log css log style
Last synced: 27 days ago
JSON representation
Tiny utility for formatting console output with CSS.
- Host: GitHub
- URL: https://github.com/uzmoi/log-styling
- Owner: uzmoi
- License: mit
- Created: 2021-06-16T08:14:39.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-08-13T12:22:49.000Z (over 3 years ago)
- Last Synced: 2024-10-31T07:20:47.743Z (about 2 months ago)
- Topics: console, console-log, css, log, style
- Language: TypeScript
- Homepage: https://rizzzse.github.io/log-styling/
- Size: 130 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# log-styling
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![npm version](https://img.shields.io/npm/v/log-styling/latest.svg?logo=npm)](https://www.npmjs.com/package/log-styling)
[![TypeDoc](https://img.shields.io/badge/document-TypeDoc-green.svg)](https://typedoc.org)Tiny utility for formatting console output.
It provides an easier-to-use interface than the printf-like console.log.
See also .
## example
```js
import { styled, style, resetStyle, object, generic, log } from "log-styling";const heading = (text) => styled(`
font-size: 1.1em;
font-weight: bold;
text-decoration: underline;
`, `# ${text}\n`);const bold = (text) => styled("font-weight: bold", text);
log(console.log, [
heading("Styled text (styles can be nested)"),
styled("color: lightgreen", [
"Lightgreen letters.\n",
style("color: yellow"),
"Yellow letters.\n",
style("background: black"),
"Lightgreen letters on a black background.\n",
resetStyle,
"Lightgreen letters.\n",
bold("Bold lightgreen letters.\n"),
]),
"Unstyled letters.",
heading("Any values"),
object({ answer: 42, bool: true }),
"\n",
object(Symbol.toPrimitive),
"\n",
generic(/[Rr]egexp?/),
]);
```