• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yiming-liao / logry / 15847159054

24 Jun 2025 09:49AM UTC coverage: 96.514% (-0.2%) from 96.733%
15847159054

push

github

yiming-liao
refactor(core): restructure logger pipeline and unify formatter

- Moved normalization and formatting steps from Logger to Transporters, aligning with Handler behavior.
- Relocated HandlerManager into core module due to tight coupling with Logger logic.
- Refactored Logger class into layered structure for better separation of concerns and extensibility.
- Unified formatter for all platforms; replaced platform separation with type-based strategy.
- Added edge support via  module to ensure compatibility without Node.js globals.
- Introduced  module exposing base handler classes (BaseHandler, NodeHandler, BrowserHandler, etc.) for developer extension.
- Cleaned up examples and benchmarks for clarity.
- Reorganized and updated test suite under .

449 of 499 branches covered (89.98%)

Branch coverage included in aggregate %.

2153 of 2176 new or added lines in 88 files covered. (98.94%)

17 existing lines in 3 files now uncovered.

4175 of 4292 relevant lines covered (97.27%)

4.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.32
/src/modules/normalizers/fields/normalize-timestamp.ts
1
import type {
1✔
2
  NormalizeFieldOptions,
1✔
3
  NormalizeTimestampExtraOptions,
1✔
4
} from "@/modules/normalizers/types";
1✔
5
import type {
1✔
6
  NormalizedTimestamp,
1✔
7
  RawTimestamp,
1✔
8
  SnapshotLogFields,
1✔
9
} from "@/shared/types/log-fields";
1✔
10
import { internalLog } from "@/internal";
1✔
11
import {
1✔
12
  DEFAULT_SHOW_TIME_ONLY,
1✔
13
  DEFAULT_TIMESTAMP_STYLE,
1✔
14
  DEFAULT_USE_UTC,
1✔
15
} from "@/modules/normalizers/constants";
1✔
16
import { buildTimestampString } from "@/modules/normalizers/utils/build-timestamp-string";
1✔
17
import { tryCustomNormalizer } from "@/modules/normalizers/utils/try-custom-normalizer";
1✔
18

1✔
19
export type TimestampStyle = "raw" | "pretty" | "iso" | "epoch";
1✔
20

1✔
21
export const normalizeTimestamp = (
1✔
22
  fieldValue: RawTimestamp,
4✔
23
  raw: SnapshotLogFields,
4✔
24
  options: NormalizeFieldOptions<
4✔
25
    RawTimestamp,
4✔
26
    NormalizedTimestamp,
4✔
27
    NormalizeTimestampExtraOptions
4✔
28
  > = {},
4✔
29
): NormalizedTimestamp => {
4✔
30
  const {
4✔
31
    style = DEFAULT_TIMESTAMP_STYLE,
4✔
32
    useUTC = DEFAULT_USE_UTC,
4✔
33
    showTimeOnly = DEFAULT_SHOW_TIME_ONLY,
4✔
34
    customNormalizer,
4✔
35
  } = options;
4✔
36

4✔
37
  // Use custom normalizer if provided
4✔
38
  const customized = tryCustomNormalizer({
4✔
39
    label: "timestamp",
4✔
40
    input: { fieldValue, raw },
4✔
41
    customNormalizer,
4✔
42
  });
4✔
43
  if (customized) {
4!
44
    return customized;
×
45
  }
×
46

4✔
47
  switch (style) {
4✔
48
    case "raw":
4!
NEW
49
      return fieldValue;
×
50
    case "iso":
4!
NEW
51
      return new Date(fieldValue).toISOString();
×
52
    case "epoch":
4!
NEW
53
      return Math.floor(fieldValue / 1000);
×
54
    case "pretty":
4✔
55
      return buildTimestampString({
4✔
56
        timestamp: fieldValue,
4✔
57
        useUTC,
4✔
58
        showTimeOnly,
4✔
59
      });
4✔
60
    default:
4!
61
      internalLog({
×
62
        type: "warn",
×
63
        message: `Unknown timestamp style "${style}", using "pretty" as fallback.`,
×
64
      });
×
NEW
65
      return buildTimestampString({
×
NEW
66
        timestamp: fieldValue,
×
NEW
67
        useUTC,
×
NEW
68
        showTimeOnly,
×
NEW
69
      });
×
70
  }
4✔
71
};
4✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc