UNPKG

chocolog

Version:

A highlighted android-style logger

210 lines 5.88 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const fs_1 = __importDefault(require("fs")); const node_fetch_1 = __importDefault(require("node-fetch")); const index_1 = require("./index"); // https://raw.githubusercontent.com/highlightjs/highlight.js/master/src/styles/vs2015.css async function sample() { const log = index_1.cLog.getLogger("Sample"); // await log.setDefaultTheme() index_1.cLog.use12Hour = true; log.enableAll(); log.use12Hour = true; const css = "https://raw.githubusercontent.com/highlightjs/highlight.js/master/src/styles/agate.css"; index_1.cLog.setCssTheme(await node_fetch_1.default(css).then((v) => v.text())); // 1 index_1.cLog.d("🤔"); index_1.cLog.d("thinking face", "🤔"); index_1.cLog.d("faces", "🤔", "🙃", "😗"); // 2 index_1.cLog.i("Primitives", 37, " ", true, " ", null); index_1.cLog.i("Object", { thinking: "🤔", upsideDown: "🙃", }); index_1.cLog.i(["LoLInsect", "Detected"]); const mp = new Map(); mp.set("Top", "Teemo"); mp.set("Mid", "Riven"); mp.set("ADCarry", "Ezreal"); index_1.cLog.i("Loading", mp); index_1.cLog.i("Oops", new Error("Trolling")); index_1.cLog.i("Fn", (str) => `Hello, ${str}!`); const cd = fs_1.default.readFileSync(process.cwd() + "/example.js", { encoding: "utf8" }); index_1.cLog.d(new Date(Date.now())); const code = index_1.cLog.code(cd, "Code Sample", "javascript"); index_1.cLog.d("Length", code.length); // 9. set log level // log.setLevel("WARN") log.v("Verbose"); log.d("Debug"); log.i("Info"); log.w("Warning"); log.e("Error"); log.wtf("Assert"); // log.enableAll() // end log.i("Finish~"); await themeTest(); } async function themeTest() { const themes = [ "a11y-dark", "a11y-light", "agate", "an-old-hope", "androidstudio", "arduino-light", "arta", "ascetic", "atelier-cave-dark", "atelier-cave-light", "atelier-dune-dark", "atelier-dune-light", "atelier-estuary-dark", "atelier-estuary-light", "atelier-forest-dark", "atelier-forest-light", "atelier-heath-dark", "atelier-heath-light", "atelier-lakeside-dark", "atelier-lakeside-light", "atelier-plateau-dark", "atelier-plateau-light", "atelier-savanna-dark", "atelier-savanna-light", "atelier-seaside-dark", "atelier-seaside-light", "atelier-sulphurpool-dark", "atelier-sulphurpool-light", "atom-one-dark-reasonable", "atom-one-dark", "atom-one-light", "brown-paper", "codepen-embed", "color-brewer", "darcula", "dark", "darkula", "default", "docco", "dracula", "far", "foundation", "github-gist", "github", "gml", "googlecode", "grayscale", "gruvbox-dark", "gruvbox-light", "hopscotch", "hybrid", "idea", "ir-black", "isbl-editor-dark", "isbl-editor-light", "kimbie.dark", "kimbie.light", "lightfair", "magula", "mono-blue", "monokai-sublime", "monokai", "nord", "obsidian", "ocean", "paraiso-dark", "paraiso-light", "pojoaque", "purebasic", "qtcreator_dark", "qtcreator_light", "railscasts", "rainbow", "routeros", "school-book", "shades-of-purple", "solarized-dark", "solarized-light", "sunburst", "tomorrow-night-blue", "tomorrow-night-bright", "tomorrow-night-eighties", "tomorrow-night", "tomorrow", "vs", "vs2015", "xcode", "xt256", "zenburn", ]; for (const theme of themes) { await index_1.cLog.setStyleGithub(theme); index_1.cLog.code(sampleCode, theme, "javascript"); } } const sampleCode = "" + `function test() { const date = Date.now(); console.log(\`Hello, \${date}!\`); }`; function perform() { const start = Date.now(); index_1.cLog.d("Performance Test"); console.log(Date.now() - start); } // perform() sample(); // logUnicode() async function test() { const log = new index_1.ChocoLog("Test"); log.d(5353); log.d(true); log.d({ aa: "Kkirodeasu", cd: "Holla!", }); const mp = new Map(); mp.set("Top", "Teemo"); mp.set("Mid", "Riven"); mp.set("ADCarry", "Ezreal"); index_1.cLog.i("Loading", mp); // Error index_1.cLog.i("Oops", new Error("Trolling")); // Function.. (not correctly) index_1.cLog.i("Fn", (str) => `Hello, ${str}!`); } class Claz { constructor() { this.test = 53; } hello() { // dummy } } function logUnicode() { for (let i = 0; i <= 255; i += 1) { let block = ""; for (let j = 0; j < 16; j += 1) { block += (i * 16 * 16 + j * 16).toString(16).toUpperCase().padStart(4, "0") + " "; for (let k = 0; k < 16; k += 1) { const n = k + j * 16 + i * 16 * 16; if (n >= 0x10000) { break; } if (i === 0 && j === 9) { break; } block += String.fromCodePoint(n); block += "|"; } block += "\n"; } index_1.cLog.i("Unicode", block); } } //# sourceMappingURL=launch.js.map