Skip to content

Commit 982f6ad

Browse files
marco-ippolitonodejs-github-bot
authored andcommitted
util: move util.log to eol
PR-URL: #52744 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Ulises Gascón <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 1d817dc commit 982f6ad

File tree

5 files changed

+5
-141
lines changed

5 files changed

+5
-141
lines changed

doc/api/deprecations.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,9 @@ The `util.isUndefined()` API has been removed. Please use
13761376

13771377
<!-- YAML
13781378
changes:
1379+
- version: REPLACEME
1380+
pr-url: https://github.com/nodejs/node/pull/52744
1381+
description: End-of-Life deprecation.
13791382
- version: v22.0.0
13801383
pr-url: https://github.com/nodejs/node/pull/50488
13811384
description: Runtime deprecation.
@@ -1387,9 +1390,9 @@ changes:
13871390
description: Documentation-only deprecation.
13881391
-->
13891392

1390-
Type: Runtime
1393+
Type: End-of-Life
13911394

1392-
The [`util.log()`][] API has been deprecated because it's an unmaintained
1395+
The `util.log()` API has been removed because it's an unmaintained
13931396
legacy API that was exposed to user land by accident. Instead,
13941397
consider the following alternatives based on your specific needs:
13951398

doc/api/util.md

-20
Original file line numberDiff line numberDiff line change
@@ -2950,26 +2950,6 @@ util.isArray({});
29502950
// Returns: false
29512951
```
29522952
2953-
### `util.log(string)`
2954-
2955-
<!-- YAML
2956-
added: v0.3.0
2957-
deprecated: v6.0.0
2958-
-->
2959-
2960-
> Stability: 0 - Deprecated: Use a third party module instead.
2961-
2962-
* `string` {string}
2963-
2964-
The `util.log()` method prints the given `string` to `stdout` with an included
2965-
timestamp.
2966-
2967-
```js
2968-
const util = require('node:util');
2969-
2970-
util.log('Timestamped message.');
2971-
```
2972-
29732953
[Common System Errors]: errors.md#common-system-errors
29742954
[Custom inspection functions on objects]: #custom-inspection-functions-on-objects
29752955
[Custom promisified functions]: #custom-promisified-functions

lib/util.js

-49
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,7 @@
2323

2424
const {
2525
ArrayIsArray,
26-
ArrayPrototypeJoin,
2726
ArrayPrototypePop,
28-
Date,
29-
DatePrototypeGetDate,
30-
DatePrototypeGetHours,
31-
DatePrototypeGetMinutes,
32-
DatePrototypeGetMonth,
33-
DatePrototypeGetSeconds,
3427
Error,
3528
ErrorCaptureStackTrace,
3629
FunctionPrototypeBind,
@@ -42,7 +35,6 @@ const {
4235
ObjectSetPrototypeOf,
4336
ObjectValues,
4437
ReflectApply,
45-
StringPrototypePadStart,
4638
StringPrototypeToWellFormed,
4739
} = primordials;
4840

@@ -89,14 +81,6 @@ function lazyAbortController() {
8981

9082
let internalDeepEqual;
9183

92-
/**
93-
* @param {number} n
94-
* @returns {string}
95-
*/
96-
function pad(n) {
97-
return StringPrototypePadStart(n.toString(), 2, '0');
98-
}
99-
10084
/**
10185
* @param {string} code
10286
* @returns {string}
@@ -134,35 +118,6 @@ function styleText(format, text) {
134118
return `${escapeStyleCode(formatCodes[0])}${text}${escapeStyleCode(formatCodes[1])}`;
135119
}
136120

137-
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
138-
'Oct', 'Nov', 'Dec'];
139-
140-
/**
141-
* @returns {string} 26 Feb 16:19:34
142-
*/
143-
function timestamp() {
144-
const d = new Date();
145-
const t = ArrayPrototypeJoin([
146-
pad(DatePrototypeGetHours(d)),
147-
pad(DatePrototypeGetMinutes(d)),
148-
pad(DatePrototypeGetSeconds(d)),
149-
], ':');
150-
return `${DatePrototypeGetDate(d)} ${months[DatePrototypeGetMonth(d)]} ${t}`;
151-
}
152-
153-
let console;
154-
/**
155-
* Log is just a thin wrapper to console.log that prepends a timestamp
156-
* @deprecated since v6.0.0
157-
* @type {(...args: any[]) => void}
158-
*/
159-
function log(...args) {
160-
if (!console) {
161-
console = require('internal/console/global');
162-
}
163-
console.log('%s - %s', timestamp(), format(...args));
164-
}
165-
166121
/**
167122
* Inherit the prototype methods from one constructor into another.
168123
*
@@ -325,10 +280,6 @@ module.exports = {
325280
}
326281
return internalDeepEqual(a, b);
327282
},
328-
log: deprecate(log,
329-
'The `util.log API is deprecated. ' +
330-
'Please use console.log() with a custom formatter or a third-party logger instead.',
331-
'DEP0059'),
332283
promisify,
333284
stripVTControlCharacters,
334285
toUSVString(input) {

test/parallel/test-fs-write-file-buffer.js

-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
'use strict';
2323
require('../common');
24-
const util = require('util');
2524
const fs = require('fs');
2625

2726
let data = [
@@ -50,5 +49,3 @@ tmpdir.refresh();
5049

5150
const buf = Buffer.from(data, 'base64');
5251
fs.writeFileSync(tmpdir.resolve('test.jpg'), buf);
53-
54-
util.log('Done!');

test/parallel/test-util-log.js

-67
This file was deleted.

0 commit comments

Comments
 (0)