Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,23 @@ jobs:
run: yarn install --immutable
- name: Run test 🔍
run: yarn test:coverage
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel: true
flag-name: "@tsed/logger"
path-to-lcov: './packages/logger/coverage/lcov.info'

coveralls:
needs: test
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
# - name: Coveralls
# uses: coverallsapp/github-action@master
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# parallel: true
# flag-name: "@tsed/logger"
# path-to-lcov: './packages/logger/coverage/lcov.info'
#
# coveralls:
# needs: test
# runs-on: ubuntu-latest
# steps:
# - name: Coveralls Finished
# uses: coverallsapp/github-action@master
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# parallel-finished: true

build:
runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"postinstall": "cd docs && yarn install && cd ..",
"clean": "monorepo clean workspace",
"test": "yarn test:lint && yarn test:coverage",
"test:unit": "lerna run test",
"test:ci": "lerna run test:ci",
"test:coverage": "yarn test:unit --stream",
"test:unit": "vitest run",
"test:ci": "vitest run --coverage --coverage.thresholds.autoUpdate=true",
"test:coverage": "vitest run --coverage --coverage.thresholds.autoUpdate=true",
"test:lint": "eslint '**/*.{ts,js}'",
"test:lint:fix": "yarn test:lint --fix",
"build": "monorepo build --verbose",
Expand Down
10 changes: 2 additions & 8 deletions packages/logger-pattern-layout/src/common/PatternLayout.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import "../node/index.js";

import {LogEvent} from "@tsed/logger";
import {dateFormat, ISO8601_WITH_TZ_OFFSET_FORMAT, LogEvent} from "@tsed/logger";
import {levels} from "@tsed/logger";
// @ts-ignore
import * as dateFormat from "date-format";
import * as os from "os";

import {formatter} from "./fn/formatter.js";
Expand Down Expand Up @@ -91,43 +89,43 @@
};
});

it("should default to `time logLevel loggerName - message`", () => {

Check warning on line 92 in packages/logger-pattern-layout/src/common/PatternLayout.spec.ts

View workflow job for this annotation

GitHub Actions / lint

Test has no assertions

Check warning on line 92 in packages/logger-pattern-layout/src/common/PatternLayout.spec.ts

View workflow job for this annotation

GitHub Actions / lint

Test has no assertions
testPattern(tokens, null, `22:29:38 DEBUG multiple.levels.of.tests - this is a test${EOL}`);
});

it("%r should output time only", () => {

Check warning on line 96 in packages/logger-pattern-layout/src/common/PatternLayout.spec.ts

View workflow job for this annotation

GitHub Actions / lint

Test has no assertions

Check warning on line 96 in packages/logger-pattern-layout/src/common/PatternLayout.spec.ts

View workflow job for this annotation

GitHub Actions / lint

Test has no assertions
testPattern(tokens, "%r", "22:29:38");
});

it("%p should output the log level", () => {

Check warning on line 100 in packages/logger-pattern-layout/src/common/PatternLayout.spec.ts

View workflow job for this annotation

GitHub Actions / lint

Test has no assertions

Check warning on line 100 in packages/logger-pattern-layout/src/common/PatternLayout.spec.ts

View workflow job for this annotation

GitHub Actions / lint

Test has no assertions
testPattern(tokens, "%p", "DEBUG");
});

it("%j should output the json formatted data", () => {

Check warning on line 104 in packages/logger-pattern-layout/src/common/PatternLayout.spec.ts

View workflow job for this annotation

GitHub Actions / lint

Test has no assertions

Check warning on line 104 in packages/logger-pattern-layout/src/common/PatternLayout.spec.ts

View workflow job for this annotation

GitHub Actions / lint

Test has no assertions
testPattern(tokens, "%j", '["this is a test"]');
});

it("%c should output the log category", () => {

Check warning on line 108 in packages/logger-pattern-layout/src/common/PatternLayout.spec.ts

View workflow job for this annotation

GitHub Actions / lint

Test has no assertions

Check warning on line 108 in packages/logger-pattern-layout/src/common/PatternLayout.spec.ts

View workflow job for this annotation

GitHub Actions / lint

Test has no assertions
testPattern(tokens, "%c", "multiple.levels.of.tests");
});

it("%m should output the log data", () => {

Check warning on line 112 in packages/logger-pattern-layout/src/common/PatternLayout.spec.ts

View workflow job for this annotation

GitHub Actions / lint

Test has no assertions

Check warning on line 112 in packages/logger-pattern-layout/src/common/PatternLayout.spec.ts

View workflow job for this annotation

GitHub Actions / lint

Test has no assertions
testPattern(tokens, "%m", "this is a test");
});

it("%n should output a new line", () => {

Check warning on line 116 in packages/logger-pattern-layout/src/common/PatternLayout.spec.ts

View workflow job for this annotation

GitHub Actions / lint

Test has no assertions

Check warning on line 116 in packages/logger-pattern-layout/src/common/PatternLayout.spec.ts

View workflow job for this annotation

GitHub Actions / lint

Test has no assertions
testPattern(tokens, "%n", EOL);
});

it("%h should output hostname", () => {

Check warning on line 120 in packages/logger-pattern-layout/src/common/PatternLayout.spec.ts

View workflow job for this annotation

GitHub Actions / lint

Test has no assertions

Check warning on line 120 in packages/logger-pattern-layout/src/common/PatternLayout.spec.ts

View workflow job for this annotation

GitHub Actions / lint

Test has no assertions
testPattern(tokens, "%h", "hostname");
});

it("%z should output pid", () => {

Check warning on line 124 in packages/logger-pattern-layout/src/common/PatternLayout.spec.ts

View workflow job for this annotation

GitHub Actions / lint

Test has no assertions

Check warning on line 124 in packages/logger-pattern-layout/src/common/PatternLayout.spec.ts

View workflow job for this annotation

GitHub Actions / lint

Test has no assertions
testPattern(tokens, "%z", process.pid.toString());
});

it("%c should handle category names like java-style package names", () => {

Check warning on line 128 in packages/logger-pattern-layout/src/common/PatternLayout.spec.ts

View workflow job for this annotation

GitHub Actions / lint

Test has no assertions

Check warning on line 128 in packages/logger-pattern-layout/src/common/PatternLayout.spec.ts

View workflow job for this annotation

GitHub Actions / lint

Test has no assertions
testPattern(tokens, "%c{1}", "tests");
testPattern(tokens, "%c{2}", "of.tests");
testPattern(tokens, "%c{3}", "levels.of.tests");
Expand All @@ -141,11 +139,7 @@
});

it("%d should allow for format specification", () => {
testPattern(
tokens,
"%d{ISO8601_WITH_TZ_OFFSET}",
dateFormat.asString(dateFormat.ISO8601_WITH_TZ_OFFSET_FORMAT, logEvent.startTime, undefined)
);
testPattern(tokens, "%d{ISO8601_WITH_TZ_OFFSET}", dateFormat(ISO8601_WITH_TZ_OFFSET_FORMAT, logEvent.startTime));
testPattern(tokens, "%d{ISO8601}", "2017-06-18T22:29:38.234");
testPattern(tokens, "%d{ABSOLUTE}", "22:29:38.234");
testPattern(tokens, "%d{DATE}", "18 06 2017 22:29:38.234");
Expand Down
26 changes: 16 additions & 10 deletions packages/logger-pattern-layout/src/common/components/date.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
import {LogEvent} from "@tsed/logger";
// @ts-ignore
import * as dateFormat from "date-format";
import {
ABSOLUTETIME_FORMAT,
dateFormat as serialize,
DATETIME_FORMAT,
ISO8601_FORMAT,
ISO8601_WITH_TZ_OFFSET_FORMAT,
LogEvent
} from "@tsed/logger";

import {formatter} from "../fn/formatter.js";
import type {FormatterOptions} from "../types/FormatterOptions.js";

formatter("d", (loggingEvent: LogEvent, specifier: string, {timezoneOffset}: FormatterOptions): string => {
let format = dateFormat.ISO8601_FORMAT;
let format = ISO8601_FORMAT;

if (specifier) {
format = specifier;
// Pick up special cases
if (format === "ISO8601") {
format = dateFormat.ISO8601_FORMAT;
format = ISO8601_FORMAT;
} else if (format === "ISO8601_WITH_TZ_OFFSET") {
format = dateFormat.ISO8601_WITH_TZ_OFFSET_FORMAT;
format = ISO8601_WITH_TZ_OFFSET_FORMAT;
} else if (format === "ABSOLUTE") {
format = dateFormat.ABSOLUTETIME_FORMAT;
format = ABSOLUTETIME_FORMAT;
} else if (format === "DATE") {
format = dateFormat.DATETIME_FORMAT;
format = DATETIME_FORMAT;
}
}
// Format the date
return dateFormat.asString(format, loggingEvent.startTime, timezoneOffset);
return serialize(format, loggingEvent.startTime, timezoneOffset);
});

formatter("r", (loggingEvent: LogEvent, _, {timezoneOffset}): string => {
return dateFormat.asString("hh:mm:ss", loggingEvent.startTime, timezoneOffset);
return serialize("hh:mm:ss", loggingEvent.startTime, timezoneOffset);
});
2 changes: 1 addition & 1 deletion packages/logger-pattern-layout/src/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* @file Automatically generated by @tsed/barrels.
*/
export * from "./PatternLayout.js";
export * from "./components/categoryName.js";
export * from "./components/colors.js";
export * from "./components/date.js";
Expand All @@ -14,6 +13,7 @@ export * from "./components/pid.js";
export * from "./components/userDefined.js";
export * from "./decorators/Formatter.js";
export * from "./fn/formatter.js";
export * from "./PatternLayout.js";
export * from "./registries/formatterRegistry.js";
export * from "./types/FormatterHandler.js";
export * from "./types/FormatterOptions.js";
Expand Down
1 change: 0 additions & 1 deletion packages/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
"homepage": "https://github.com/tsedio/logger",
"dependencies": {
"colors": "1.4.0",
"date-format": "^4.0.14",
"semver": "^7.7.2",
"tslib": "2.8.1"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/logger/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ export * from "./layouts/decorators/layout.js";
export * from "./layouts/fn/layout.js";
export * from "./layouts/interfaces/BasicLayoutConfiguration.js";
export * from "./layouts/registries/LayoutsRegistry.js";
export * from "./layouts/utils/StringUtils.js";
export * from "./layouts/utils/colorizeUtils.js";
export * from "./layouts/utils/format.js";
export * from "./layouts/utils/logEventToObject.js";
export * from "./layouts/utils/StringUtils.js";
export * from "./layouts/utils/timestampLevelAndCategory.js";
export * from "./logger/class/Logger.js";
export * from "./logger/class/LoggerAppenders.js";
export * from "./logger/utils/tableUtils.js";
export * from "./utils/dateFormat.js";
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// @ts-ignore
import * as dateFormat from "date-format";

import {LogEvent} from "../../core/LogEvent.js";
import {dateFormat} from "../../utils/dateFormat.js";
import {colorize} from "./colorizeUtils.js";
import {StringUtils} from "./StringUtils.js";

export function timestampLevelAndCategory(loggingEvent: LogEvent, colour: any, timezoneOffset: number | undefined) {
return colorize(
StringUtils.format(
"[%s] [%s] [%s] - ",
dateFormat.asString(loggingEvent.startTime, timezoneOffset),
dateFormat(loggingEvent.startTime, timezoneOffset),
loggingEvent.formattedLevel,
loggingEvent.categoryName
),
Expand Down
Loading
Loading