fullstack-build / tslog

📝 tslog - Universal Logger for TypeScript and JavaScript
https://tslog.js.org
MIT License
1.35k stars 63 forks source link

allow for custom placeholders in the template string #244

Closed olafbuitelaar closed 1 year ago

olafbuitelaar commented 1 year ago

This PR enables the support of custom placeholders in the prettyLogTemplate string. The placeholders can be defined, be setting the overwrite.addPlaceholders function. For example to define the placeholder {{custom}}, add following method;

overwrite: {
  addPlaceholders: (logObjMeta: IMeta, placeholderValues: Record<string, string>) => {
    placeholderValues["custom"] = "test";
  },
}
terehov commented 1 year ago

Thank you. Can you also add to the documentation (README.md) please, so that our users understand how to use it?

olafbuitelaar commented 1 year ago

i've added some info about the feature

codecov-commenter commented 1 year ago

Codecov Report

Merging #244 (076076d) into master (0e751a5) will increase coverage by 0.01%. The diff coverage is 100.00%.

:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master     #244      +/-   ##
==========================================
+ Coverage   98.78%   98.79%   +0.01%     
==========================================
  Files           6        6              
  Lines         326      328       +2     
  Branches      158      159       +1     
==========================================
+ Hits          322      324       +2     
  Misses          4        4              
Files Changed Coverage Δ
src/BaseLogger.ts 98.01% <100.00%> (+0.03%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more