Skip to content

Commit 0509215

Browse files
committed
Added log.hadLineBreak tracking to log methods to support automatic insertion
1 parent 6c13835 commit 0509215

File tree

4 files changed

+28
-21
lines changed

4 files changed

+28
-21
lines changed

chatgpt-auto-continue/utils/bump/js-resources.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@
3232

3333
// Define FUNCTIONS
3434

35-
const log = {
36-
info(msg) { console.log(bw + msg + nc) },
37-
working(msg) { console.log(by + msg + nc) },
38-
success(msg) { console.log(bg + msg + nc) }
39-
}
35+
const log = {};
36+
['info', 'working', 'success'].forEach(lvl => {
37+
log[lvl] = function(msg) {
38+
const logColor = lvl == 'info' ? bw : lvl == 'working' ? by : lvl == 'success' ? bg : ''
39+
console.log(logColor + msg + nc) ; log.hadLineBreak = msg.toString().endsWith('\n')
40+
}
41+
})
4042

4143
function fetchData(url) {
4244
if (typeof fetch == 'undefined') // polyfill for Node.js < v21

chatgpt-infinity/utils/bump/js-resources.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@
3232

3333
// Define FUNCTIONS
3434

35-
const log = {
36-
info(msg) { console.log(bw + msg + nc) },
37-
working(msg) { console.log(by + msg + nc) },
38-
success(msg) { console.log(bg + msg + nc) }
39-
}
35+
const log = {};
36+
['info', 'working', 'success'].forEach(lvl => {
37+
log[lvl] = function(msg) {
38+
const logColor = lvl == 'info' ? bw : lvl == 'working' ? by : lvl == 'success' ? bg : ''
39+
console.log(logColor + msg + nc) ; log.hadLineBreak = msg.toString().endsWith('\n')
40+
}
41+
})
4042

4143
function fetchData(url) {
4244
if (typeof fetch == 'undefined') // polyfill for Node.js < v21

chatgpt-widescreen/utils/bump/js-resources.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@
2828

2929
// Define FUNCTIONS
3030

31-
const log = {
32-
info(msg) { console.log(bw + msg + nc) },
33-
working(msg) { console.log(by + msg + nc) },
34-
success(msg) { console.log(bg + msg + nc) }
35-
}
31+
const log = {};
32+
['info', 'working', 'success'].forEach(lvl => {
33+
log[lvl] = function(msg) {
34+
const logColor = lvl == 'info' ? bw : lvl == 'working' ? by : lvl == 'success' ? bg : ''
35+
console.log(logColor + msg + nc) ; log.hadLineBreak = msg.toString().endsWith('\n')
36+
}
37+
})
3638

3739
function fetchData(url) {
3840
if (typeof fetch == 'undefined') // polyfill for Node.js < v21

utils/bump/js-resources.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@
2727

2828
// Define FUNCTIONS
2929

30-
const log = {
31-
dev(msg) { if (devMode) console.log(msg) },
32-
info(msg) { console.log(bw + msg + nc) },
33-
working(msg) { console.log(by + msg + nc) },
34-
success(msg) { console.log(bg + msg + nc) }
35-
}
30+
const log = {};
31+
['dev', 'info', 'working', 'success'].forEach(lvl => {
32+
log[lvl] = function(msg) {
33+
const logColor = lvl == 'info' ? bw : lvl == 'working' ? by : lvl == 'success' ? bg : ''
34+
console.log(logColor + msg + nc) ; log.hadLineBreak = msg.toString().endsWith('\n')
35+
}
36+
})
3637

3738
async function findUserJS(dir = './') {
3839
const userJSfiles = []

0 commit comments

Comments
 (0)