Skip to content

Commit 028f350

Browse files
committed
Subject: Pretty JSON in Logger
Issue: #3
1 parent a2601cf commit 028f350

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

readme.md

+17
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ This is a list of code fragments for the copy / paste tool on yours keyboard. I
33

44
<!-- TOC depthFrom:2 -->
55

6+
- [Base Services](#base-services)
7+
- [Pretty JSON in Logger](#pretty-json-in-logger)
68
- [Spreadsheets](#spreadsheets)
79
- [Common elements for spreadsheets](#common-elements-for-spreadsheets)
810
- [Round to day](#round-to-day)
@@ -16,6 +18,21 @@ This is a list of code fragments for the copy / paste tool on yours keyboard. I
1618

1719
<!-- /TOC -->
1820

21+
## Base Services
22+
23+
### Pretty JSON in Logger
24+
_example [/issues/3](/issues/3)_
25+
```js
26+
function ll(){
27+
var args = [];
28+
for (var i = 0; i < arguments.length; i++) {
29+
args.push(typeof arguments[i] === 'object' ? JSON.stringify(arguments[i], null, ' ') : arguments[i]);
30+
}
31+
if(typeof args[0] === 'string' && !/%s/.test(args[0]))
32+
args.unshift(Array(args.length).join('\n%s'));
33+
Logger.log.apply(Logger, args);
34+
}
35+
```
1936
## Spreadsheets
2037

2138
### Common elements for spreadsheets

0 commit comments

Comments
 (0)