Buckets:
ktongue/docker_container / .cache /opencode /node_modules /pino /benchmarks /utils /wrap-log-level.js
| const { readFileSync } = require('node:fs') | |
| const vm = require('vm') | |
| const { join } = require('node:path') | |
| const code = readFileSync( | |
| join(__dirname, '..', '..', 'node_modules', 'loglevel', 'lib', 'loglevel.js') | |
| ) | |
| const { Console } = require('console') | |
| function build (dest) { | |
| const sandbox = { | |
| module: {}, | |
| console: new Console(dest, dest) | |
| } | |
| const context = vm.createContext(sandbox) | |
| const script = new vm.Script(code) | |
| script.runInContext(context) | |
| const loglevel = sandbox.log | |
| const originalFactory = loglevel.methodFactory | |
| loglevel.methodFactory = function (methodName, logLevel, loggerName) { | |
| const rawMethod = originalFactory(methodName, logLevel, loggerName) | |
| return function () { | |
| const time = new Date() | |
| let array | |
| if (typeof arguments[0] === 'string') { | |
| arguments[0] = '[' + time.toISOString() + '] ' + arguments[0] | |
| rawMethod.apply(null, arguments) | |
| } else { | |
| array = new Array(arguments.length + 1) | |
| array[0] = '[' + time.toISOString() + ']' | |
| for (var i = 0; i < arguments.length; i++) { | |
| array[i + 1] = arguments[i] | |
| } | |
| rawMethod.apply(null, array) | |
| } | |
| } | |
| } | |
| loglevel.setLevel(loglevel.levels.INFO) | |
| return loglevel | |
| } | |
| module.exports = build | |
| if (require.main === module) { | |
| const loglevel = build(process.stdout) | |
| loglevel.info('hello') | |
| loglevel.info({ hello: 'world' }) | |
| loglevel.info('hello %j', { hello: 'world' }) | |
| } | |
Xet Storage Details
- Size:
- 1.48 kB
- Xet hash:
- a0bcd6b4510ec58632bd5a93cb7377f2d3bce565094168e21bad39ceae4ac566
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.