彩色控制台日志使日志文件更大?

时间:2021-02-06 00:17:21

For example... Say I am running a script with Forever https://www.npmjs.com/package/forever for a week while recording a log file of the node applications output.

例如......假设我正在运行一个带有Forever https://www.npmjs.com/package/forever的脚本一周,同时记录节点应用程序输出的日志文件。

If I say included colors would it make that filesize bigger? Dealing with crazy sizes logs 5gb+ with the colors on. So curious if I could shave even 10mb without it?

如果我说包含颜色会使文件大小更大?处理疯狂的尺寸日志5gb +与颜色。如果我能在没有它的情况下剃掉10mb那么好奇吗?

{ pass: [0,255,0], fail: [255,0,0], info: [0,255,255], warning: [255,127,80] }

{pass:[0,255,0],失败:[255,0,0],信息:[0,255,255],警告:[255,127,80]}

1 个解决方案

#1


2  

You're storing more characters to colorize log output, so yes, you will increase the log size (more data == more data). For example, check out these source lines from chalk tests:

您正在存储更多字符以着色日志输出,所以是的,您将增加日志大小(更多数据==更多数据)。例如,从粉笔测试中查看这些源代码行:

it('should style string', function () {
                                 // Notice all the extra characters
    assert.equal(chalk.underline('foo'), '\u001b[4mfoo\u001b[24m');
    assert.equal(chalk.red('foo'), '\u001b[31mfoo\u001b[39m');
    assert.equal(chalk.bgRed('foo'), '\u001b[41mfoo\u001b[49m');
});

If you absolutely need the colors for readability, so be it. But if you do w/o you can shave off some space, but there's no guarantee it'll be in the order of 10MB :)

如果您绝对需要颜色以便于阅读,那就这样吧。但是,如果你没有w / o你可以削减一些空间,但不能保证它将大约10MB :)

Another thing to note is that depending on where you're reading the logs, the color may or may not come through properly. I've run into this when looking at some raw logs on AWS. The colorized portions were pretty mangled.

另外需要注意的是,根据您阅读日志的位置,颜色可能会或可能不会正确显示。在AWS上查看一些原始日志时,我遇到了这个问题。彩色部分非常糟糕。

#1


2  

You're storing more characters to colorize log output, so yes, you will increase the log size (more data == more data). For example, check out these source lines from chalk tests:

您正在存储更多字符以着色日志输出,所以是的,您将增加日志大小(更多数据==更多数据)。例如,从粉笔测试中查看这些源代码行:

it('should style string', function () {
                                 // Notice all the extra characters
    assert.equal(chalk.underline('foo'), '\u001b[4mfoo\u001b[24m');
    assert.equal(chalk.red('foo'), '\u001b[31mfoo\u001b[39m');
    assert.equal(chalk.bgRed('foo'), '\u001b[41mfoo\u001b[49m');
});

If you absolutely need the colors for readability, so be it. But if you do w/o you can shave off some space, but there's no guarantee it'll be in the order of 10MB :)

如果您绝对需要颜色以便于阅读,那就这样吧。但是,如果你没有w / o你可以削减一些空间,但不能保证它将大约10MB :)

Another thing to note is that depending on where you're reading the logs, the color may or may not come through properly. I've run into this when looking at some raw logs on AWS. The colorized portions were pretty mangled.

另外需要注意的是,根据您阅读日志的位置,颜色可能会或可能不会正确显示。在AWS上查看一些原始日志时,我遇到了这个问题。彩色部分非常糟糕。