https://github.com/splincode/ts-debugger
web emulate console.log
https://github.com/splincode/ts-debugger
javascript-library typescript-library
Last synced: 9 months ago
JSON representation
web emulate console.log
- Host: GitHub
- URL: https://github.com/splincode/ts-debugger
- Owner: splincode
- Created: 2017-01-16T08:44:20.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-11-28T10:14:33.000Z (over 7 years ago)
- Last Synced: 2024-10-16T09:18:53.424Z (over 1 year ago)
- Topics: javascript-library, typescript-library
- Language: JavaScript
- Size: 5.86 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
### Usage
```bash
$ npm install ts-debugger --save-dev
```
Logger information:
```javascript
// example.ts
import {Logger, Level} from "ts-debugger";
declare let log: Logger;
// show string, array, object
let test = {a: 1, b: 2, c: 3};
log.debug("This is object: ", test);
/*
[DEBUG] [
"This is object: ",
{
"a": 1,
"b": 2,
"c": 3
}
]
*/
```

```javascript
log.debug("This is object: ")(test);
/* [DEBUG] This is object: Object {a: 1, b: 2, c: 3} */
```
### Warning, Error


### Example
```javascript
// polyfills.ts
import {Logger, Level} from "ts-debugger";
import "core-js/client/shim";
import "reflect-metadata";
import "ts-helpers";
require("zone.js/dist/zone");
declare let log: Logger;
declare let window: any;
if (process.env.TYPE === "prod") {
// Production
window.log = new Logger(Level.INFO);
} else {
// Development
window.log = new Logger();
Error["stackTraceLimit"] = Infinity;
require("zone.js/dist/long-stack-trace-zone");
}
log.debug(
`Level debug: ${log["levelMin"]}`,
`TYPE = ${process.env.TYPE}`,
`THEME = ${process.env.THEME}`
)();
```