Skip to content

Structured JSON Logging #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 20, 2022
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
111 changes: 56 additions & 55 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,35 @@ workflow:
when: never
- when: always

default:
interruptible: true

variables:
GIT_SUBMODULE_STRATEGY: recursive
GH_PROJECT_PATH: "MatrixAI/${CI_PROJECT_NAME}"
GH_PROJECT_URL: "https://${GITHUB_TOKEN}@github.com/${GH_PROJECT_PATH}.git"
GIT_SUBMODULE_STRATEGY: recursive
# Cache .npm
NPM_CONFIG_CACHE: "${CI_PROJECT_DIR}/tmp/npm"
# Prefer offline node module installation
NPM_CONFIG_PREFER_OFFLINE: "true"
# Homebrew cache only used by macos runner
HOMEBREW_CACHE: "${CI_PROJECT_DIR}/tmp/Homebrew"

default:
interruptible: true
before_script:
# Replace this in windows runners that use powershell
# with `mkdir -Force "$CI_PROJECT_DIR/tmp"`
- mkdir -p "$CI_PROJECT_DIR/tmp"

# Cached directories shared between jobs & pipelines per-branch per-runner
cache:
key: $CI_COMMIT_REF_SLUG
# Preserve cache even if job fails
when: 'always'
paths:
- ./tmp/npm/
# Homebrew cache is only used by the macos runner
- ./tmp/Homebrew
# Chocolatey cache is only used by the windows runner
- ./tmp/chocolatey/
# `jest` cache is configured in jest.config.js
- ./tmp/jest/

Expand All @@ -42,9 +50,10 @@ check:lint:
needs: []
script:
- >
nix-shell --run '
npm run lint;
'
nix-shell --arg ci true --run '
npm run lint;
npm run lint-shell;
'
rules:
# Runs on feature and staging commits and ignores version commits
- if: $CI_COMMIT_BRANCH =~ /^(?:feature.*|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
Expand All @@ -59,10 +68,9 @@ check:test:
needs: []
script:
- >
nix-shell --run '
npm run build --verbose;
npm test -- --ci --coverage;
'
nix-shell --arg ci true --run '
npm test -- --ci --coverage;
'
artifacts:
when: always
reports:
Expand All @@ -87,20 +95,20 @@ build:merge:
# Required for `gh pr create`
- git remote add upstream "$GH_PROJECT_URL"
- >
nix-shell -I nixpkgs=./pkgs.nix --packages gitAndTools.gh --run '
gh pr create \
--head staging \
--base master \
--title "ci: merge staging to master" \
--body "This is an automatic PR generated by the pipeline CI/CD. This will be automatically fast-forward merged if successful." \
--assignee "@me" \
--no-maintainer-edit \
--repo "$GH_PROJECT_PATH" || true;
printf "Pipeline Attempt on ${CI_PIPELINE_ID} for ${CI_COMMIT_SHA}\n\n${CI_PIPELINE_URL}" \
| gh pr comment staging \
--body-file - \
--repo "$GH_PROJECT_PATH";
'
nix-shell --arg ci true --run '
gh pr create \
--head staging \
--base master \
--title "ci: merge staging to master" \
--body "This is an automatic PR generated by the pipeline CI/CD. This will be automatically fast-forward merged if successful." \
--assignee "@me" \
--no-maintainer-edit \
--repo "$GH_PROJECT_PATH" || true;
printf "Pipeline Attempt on ${CI_PIPELINE_ID} for ${CI_COMMIT_SHA}\n\n${CI_PIPELINE_URL}" \
| gh pr comment staging \
--body-file - \
--repo "$GH_PROJECT_PATH";
'
rules:
# Runs on staging commits and ignores version commits
- if: $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
Expand All @@ -112,10 +120,10 @@ build:linux:
needs: []
script:
- >
nix-shell --run '
npm run build --verbose;
npm test -- --ci --coverage;
'
nix-shell --arg ci true --run '
npm run build --verbose;
npm test -- --ci --coverage;
'
artifacts:
when: always
reports:
Expand All @@ -140,10 +148,10 @@ build:windows:
tags:
- windows
before_script:
- choco install nodejs --version=16.14.2 -y
- refreshenv
- mkdir -Force "$CI_PROJECT_DIR/tmp"
script:
- npm config set msvs_version 2019
- .\scripts\choco-install.ps1
- refreshenv
- npm install --ignore-scripts
- $env:Path = "$(npm bin);" + $env:Path
- npm run build --verbose
Expand All @@ -165,15 +173,10 @@ build:macos:
tags:
- shared-macos-amd64
image: macos-11-xcode-12
variables:
HOMEBREW_NO_INSTALL_UPGRADE: "true"
HOMEBREW_NO_INSTALL_CLEANUP: "true"
before_script:
script:
- eval "$(brew shellenv)"
- brew install node@16
- brew link --overwrite node@16
- ./scripts/brew-install.sh
- hash -r
script:
- npm install --ignore-scripts
- export PATH="$(npm bin):$PATH"
- npm run build --verbose
Expand All @@ -197,14 +200,13 @@ build:prerelease:
- build:macos
# Don't interrupt publishing job
interruptible: false
before_script:
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
script:
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
- echo 'Publishing library prerelease'
- >
nix-shell --run '
npm publish --tag prerelease --access public;
'
nix-shell --arg ci true --run '
npm publish --tag prerelease --access public;
'
after_script:
- rm -f ./.npmrc
rules:
Expand Down Expand Up @@ -234,12 +236,12 @@ integration:merge:
GIT_DEPTH: 0
script:
- >
nix-shell -I nixpkgs=./pkgs.nix --packages gitAndTools.gh --run '
printf "Pipeline Succeeded on ${CI_PIPELINE_ID} for ${CI_COMMIT_SHA}\n\n${CI_PIPELINE_URL}" \
| gh pr comment staging \
--body-file - \
--repo "$GH_PROJECT_PATH";
'
nix-shell --arg ci true --run '
printf "Pipeline Succeeded on ${CI_PIPELINE_ID} for ${CI_COMMIT_SHA}\n\n${CI_PIPELINE_URL}" \
| gh pr comment staging \
--body-file - \
--repo "$GH_PROJECT_PATH";
'
- git remote add upstream "$GH_PROJECT_URL"
- git checkout origin/master
# Merge up to the current commit (not the latest commit)
Expand All @@ -260,14 +262,13 @@ release:distribution:
- integration:merge
# Don't interrupt publishing job
interruptible: false
before_script:
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
script:
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
- echo 'Publishing library'
- >
nix-shell --run '
npm publish --access public;
'
nix-shell --arg ci true --run '
npm publish --access public;
'
after_script:
- rm -f ./.npmrc
rules:
Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@ See the docs at: https://matrixai.github.io/js-logger/

### Publishing

Publishing is handled automatically by the staging pipeline.

Prerelease:

```sh
# npm login
npm version prepatch --preid alpha # premajor/preminor/prepatch
git push --follow-tags
```

Release:

```sh
# npm login
npm version patch # major/minor/patch
git push --follow-tags
```

Manually:

```sh
# npm login
npm version patch # major/minor/patch
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/search.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion docs/classes/default.html

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ <h3>Docs Generation</h3>
<a href="#publishing" id="publishing" style="color: inherit; text-decoration: none;">
<h3>Publishing</h3>
</a>
<p>Publishing is handled automatically by the staging pipeline.</p>
<p>Prerelease:</p>
<pre><code class="language-sh"><span class="hl-1"># npm login</span><br/><span class="hl-0">npm version prepatch --preid alpha </span><span class="hl-1"># premajor/preminor/prepatch</span><br/><span class="hl-0">git push --follow-tags</span>
</code></pre>
<p>Release:</p>
<pre><code class="language-sh"><span class="hl-1"># npm login</span><br/><span class="hl-0">npm version patch </span><span class="hl-1"># major/minor/patch</span><br/><span class="hl-0">git push --follow-tags</span>
</code></pre>
<p>Manually:</p>
<pre><code class="language-sh"><span class="hl-1"># npm login</span><br/><span class="hl-0">npm version patch </span><span class="hl-1"># major/minor/patch</span><br/><span class="hl-0">npm run build</span><br/><span class="hl-0">npm publish --access public</span><br/><span class="hl-0">git push</span><br/><span class="hl-0">git push --tags</span>
</code></pre>
</div></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class="current"><a href="modules.html">Exports</a></li><li class=" tsd-kind-namespace"><a href="modules/formatting.html">formatting</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="tsd-kind-enum"><a href="enums/LogLevel.html" class="tsd-kind-icon">Log<wbr/>Level</a></li><li class="tsd-kind-class"><a href="classes/ConsoleErrHandler.html" class="tsd-kind-icon">Console<wbr/>Err<wbr/>Handler</a></li><li class="tsd-kind-class"><a href="classes/ConsoleOutHandler.html" class="tsd-kind-icon">Console<wbr/>Out<wbr/>Handler</a></li><li class="tsd-kind-class"><a href="classes/Handler.html" class="tsd-kind-icon">Handler</a></li><li class="tsd-kind-class"><a href="classes/StreamHandler.html" class="tsd-kind-icon">Stream<wbr/>Handler</a></li><li class="tsd-kind-class"><a href="classes/default.html" class="tsd-kind-icon">default</a></li><li class="tsd-kind-interface"><a href="interfaces/ToString.html" class="tsd-kind-icon">To<wbr/>String</a></li><li class="tsd-kind-type-alias"><a href="modules.html#LogFormatter" class="tsd-kind-icon">Log<wbr/>Formatter</a></li><li class="tsd-kind-type-alias"><a href="modules.html#LogRecord" class="tsd-kind-icon">Log<wbr/>Record</a></li><li class="tsd-kind-function"><a href="modules.html#levelToString" class="tsd-kind-icon">level<wbr/>To<wbr/>String</a></li></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Legend</h2><div class="tsd-legend-group"><ul class="tsd-legend"><li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li><li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li><li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited constructor</span></li><li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited property</span></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected method</span></li></ul></div><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="assets/main.js"></script></body></html>
</div></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class="current"><a href="modules.html">Exports</a></li><li class=" tsd-kind-namespace"><a href="modules/formatting.html">formatting</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="tsd-kind-enum"><a href="enums/LogLevel.html" class="tsd-kind-icon">Log<wbr/>Level</a></li><li class="tsd-kind-class"><a href="classes/ConsoleErrHandler.html" class="tsd-kind-icon">Console<wbr/>Err<wbr/>Handler</a></li><li class="tsd-kind-class"><a href="classes/ConsoleOutHandler.html" class="tsd-kind-icon">Console<wbr/>Out<wbr/>Handler</a></li><li class="tsd-kind-class"><a href="classes/Handler.html" class="tsd-kind-icon">Handler</a></li><li class="tsd-kind-class"><a href="classes/StreamHandler.html" class="tsd-kind-icon">Stream<wbr/>Handler</a></li><li class="tsd-kind-class"><a href="classes/default.html" class="tsd-kind-icon">default</a></li><li class="tsd-kind-interface"><a href="interfaces/ToJSON.html" class="tsd-kind-icon">ToJSON</a></li><li class="tsd-kind-interface"><a href="interfaces/ToString.html" class="tsd-kind-icon">To<wbr/>String</a></li><li class="tsd-kind-type-alias"><a href="modules.html#LogData" class="tsd-kind-icon">Log<wbr/>Data</a></li><li class="tsd-kind-type-alias"><a href="modules.html#LogDataKey" class="tsd-kind-icon">Log<wbr/>Data<wbr/>Key</a></li><li class="tsd-kind-type-alias"><a href="modules.html#LogDataValue" class="tsd-kind-icon">Log<wbr/>Data<wbr/>Value</a></li><li class="tsd-kind-type-alias"><a href="modules.html#LogFormatter" class="tsd-kind-icon">Log<wbr/>Formatter</a></li><li class="tsd-kind-type-alias"><a href="modules.html#LogRecord" class="tsd-kind-icon">Log<wbr/>Record</a></li><li class="tsd-kind-variable"><a href="modules.html#hasCaptureStackTrace" class="tsd-kind-icon">has<wbr/>Capture<wbr/>Stack<wbr/>Trace</a></li><li class="tsd-kind-variable"><a href="modules.html#hasStackTraceLimit" class="tsd-kind-icon">has<wbr/>Stack<wbr/>Trace<wbr/>Limit</a></li><li class="tsd-kind-function"><a href="modules.html#evalLogData" class="tsd-kind-icon">eval<wbr/>Log<wbr/>Data</a></li><li class="tsd-kind-function"><a href="modules.html#evalLogDataValue" class="tsd-kind-icon">eval<wbr/>Log<wbr/>Data<wbr/>Value</a></li><li class="tsd-kind-function"><a href="modules.html#levelToString" class="tsd-kind-icon">level<wbr/>To<wbr/>String</a></li></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Legend</h2><div class="tsd-legend-group"><ul class="tsd-legend"><li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li><li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li><li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited constructor</span></li><li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited property</span></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-method tsd-parent-kind-class tsd-is-protected"><span class="tsd-kind-icon">Protected method</span></li></ul></div><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="assets/main.js"></script></body></html>
Loading