MCPcopy Index your code
hub / github.com/Linen-dev/linen.dev / timeLog

Method timeLog

packages/utilities/src/logger.ts:46–69  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

44 this.logger.info(name + ': ' + this._timeStamps[name]);
45 }
46 timeLog(name: string) {
47 if (this._timeStamps[name]) {
48 const timeStamp = +new Date() - +this._timeStamps[name];
49 const seconds = Math.floor(timeStamp / 1000);
50 const minutes = Math.floor(seconds / 60);
51 const hours = Math.floor(minutes / 60);
52 let timeStr = name + ':';
53 if (hours >= 1) {
54 timeStr += ' ' + hours + 'h';
55 }
56 if (minutes >= 1) {
57 timeStr += ' ' + minutes + 'm';
58 }
59 if (seconds >= 1) {
60 timeStr += ' ' + seconds + 's';
61 }
62 if (timeStamp >= 1) {
63 timeStr += ' ' + (timeStamp % 1000) + 'ms';
64 }
65 this.logger.info(timeStr);
66 return;
67 }
68 this.logger.warn(name + ' is not found');
69 }
70 timeEnd(name: string) {
71 this.timeLog(name);
72 delete this._timeStamps[name];

Callers 1

timeEndMethod · 0.95

Calls 2

infoMethod · 0.65
warnMethod · 0.65

Tested by

no test coverage detected