Console printer with a fluent API, written in Rust.
Lazer is a utility for printing to the console using a fluent API. Ported to Rust from the original TypeScript package.
Lazer helps you build, format and print complex messages to the console using an expressive fluent API.
main.rs
```rust use lazer::{lazer};
fn main() { lazer() .print("Hello,") .printspace() .printgreen("Green World") .print_ln("!") } ```
```bash $ cargo run Hello, Green World!
```
```typescript import { lazer } from "https://deno.land/x/lazer/mod.ts"
const remoteAddr = "127.0.0.1"; const method = "GET"; const path = "/a/really/really/really/long/path/here"; const status = 200; const timems = 20; const sizebytes_string = "1.10kB";
lazer()
.print('[').printutctime().print(']')
.printspace().print("-").printspace()
.printpadright(remoteAddr, 15, '')
.printspace(2)
.printpadright(method, 4, '')
.printspace(2)
.printpadright(path, 20, "")
.printspace(2)
.if(status >= 200 && status < 300)
.printgreen(status)
.elseif(status >= 300 && status < 400)
.printyellow(status)
.elseif(status >= 400)
.printred(status)
.end()
.printspace(2)
.printpadright(${time_ms}ms
, 6, "")
.printspace(2)
.println(sizebytes_string);
```
```bash $ deno run example.ts [Fri, 01 Jan 2021 00:00:00 GMT] - 127.0.0.1_ GET /a/really/really/+42 200 20ms__ 1.10kB
```
```typescript import { lazer } from "https://deno.land/x/lazer/mod.ts"
const getLinePrefix = () => { return lazer().buffer() .printyellow('[').printyellow("Line Prefix").printyellow(']') .printspace().print("-").printspace() .printyellow('[').setcoloryellow().printutctime().printyellow(']') .printspace().print("-").print_space() .return(); }
lazer() .print(getLinePrefix()) .printyellowln("This is a prefixed line of text output");
lazer() .print(getLinePrefix()) .printyellowln("This is another prefixed line of text output"); ```
```bash $ deno run example.ts [Line Prefix] - [Mon, 10 May 2021 16:31:29 GMT] - This is a prefixed line of text output [Line Prefix] - [Mon, 10 May 2021 16:31:29 GMT] - This is another prefixed line of text output
```
```typescript import { lazer } from "https://deno.land/x/lazer/mod.ts"
lazer().buffer() .setcolorred().print_ln("Some red output to buffer") .store('i am an alias');
lazer().buffer() .load('i am an alias') .print_b(); ```
```bash $ deno run example.ts Some red output to buffer
```
typescript
import { lazer } from "https://deno.land/x/lazer/mod.ts"
bash
npm i --save lazer-js
javascript
const { lazer } = require('lazer-js');