Skip to content

Add rlog package with custom logging levels and features#38

Merged
chris-okuda merged 19 commits intomainfrom
chrisokuda/sc-37723/rlog
Mar 24, 2026
Merged

Add rlog package with custom logging levels and features#38
chris-okuda merged 19 commits intomainfrom
chrisokuda/sc-37723/rlog

Conversation

@chris-okuda
Copy link
Copy Markdown
Contributor

@chris-okuda chris-okuda commented Mar 22, 2026

Scope of changes

The 'r' stands for "Rotational" 😃

  • Introduced the rlog package, which wraps the standard library's log/slog package.
  • Added custom severity levels: TRACE, FATAL, and PANIC.
  • Implemented MergeWithCustomLevels function to customize logging behavior.
  • Created Logger type with methods for Trace*, Fatal*, and Panic* logging functions.
  • Added *Attrs functions for all log levels for more performant logging using slog.LogAttrs, including the default log levels.
  • Added tests to validate logging functionality and custom levels in JSON output.
  • Added Contains, NotContains, and PanicsWithValue that perform the same functions as the require package functions of the same names to the assert package for easier testing.
  • Updated and added READMEs.

See comments for reviewer: #38 (review)

Fixes SC-37723

Type of change

  • new feature
  • bug fix
  • documentation
  • testing
  • technical debt
  • other (describe)

Author checklist

  • I have manually tested the change and/or added automation in the form of unit tests or integration tests
  • I have added new test fixtures as needed to support added tests
  • Check this box if a reviewer can merge this pull request after approval (leave it unchecked if you want to do it yourself)
  • I have moved the associated Shortcut story to "Ready for Review"

Reviewer(s) checklist

  • Any new user-facing content that has been added for this PR has been QA'ed to ensure correct grammar, spelling, and understandability.
  • Are there any TODOs in this PR that should be turned into stories?

- Introduced the rlog package, which wraps the standard library's slog package.
- Added custom severity levels: TRACE, FATAL, and PANIC.
- Implemented MergeWithCustomLevels function to customize logging behavior.
- Created Logger type with methods for TRACE, FATAL, and PANIC logging.
- Added tests to validate logging functionality and custom levels in JSON output.
- Updated README to include rlog package information.
@chris-okuda chris-okuda self-assigned this Mar 22, 2026
cursor[bot]

This comment was marked as resolved.

chris-okuda and others added 6 commits March 22, 2026 11:11
…o only uses the stdlib.

assert package  changes:

- Modernized assertion functions to accept 'any' instead of 'interface{}'
- Introduced new Contains and NotContains functions for string containment assertions.
- Introduced new PanicsWithValue function for panic assertions.
- Introduced DebugAttrs, InfoAttrs, WarnAttrs, and ErrorAttrs methods to the Logger for logging at respective slog levels with context and attributes.
- Added unit tests for each new logging method to verify correct output and level in logs.
- Updated existing tests to assert log levels for various logging scenarios.
Signed-off-by: Chris Okuda <chris@rotational.io>
Signed-off-by: Chris Okuda <chris@rotational.io>
Copy link
Copy Markdown
Contributor Author

@chris-okuda chris-okuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments for reviewer

Copy link
Copy Markdown
Contributor

@bbengfort bbengfort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work! Excited to use this for logging.

Can you create a story or stories for some follow up functionality:

  1. Ability to set a global logger and a global level with our custom handler.
  2. Shortcut functions at the package level for Info, InfoContext, etc. that use the global logger which should be the default logger if not set.
  3. Level decoder functionality as mentioned in a previous comment.

The above will make it much easier to replace zerolog in our codebase!

chris-okuda and others added 4 commits March 23, 2026 07:52
Co-authored-by: Benjamin Bengfort <benjamin@rotational.io>
Signed-off-by: Chris Okuda <chris@okuda.dev>
…tions plus testing to ensure a concurrency safe implementation
@chris-okuda
Copy link
Copy Markdown
Contributor Author

Awesome work! Excited to use this for logging.

Can you create a story or stories for some follow up functionality:

  1. Ability to set a global logger and a global level with our custom handler.
  2. Shortcut functions at the package level for Info, InfoContext, etc. that use the global logger which should be the default logger if not set.
  3. Level decoder functionality as mentioned in a previous comment.

The above will make it much easier to replace zerolog in our codebase!

I did these in here because they will be too useful to skip now.

@chris-okuda chris-okuda requested a review from bbengfort March 23, 2026 19:48
Copy link
Copy Markdown
Contributor

@bbengfort bbengfort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding that functionality!

chris-okuda and others added 3 commits March 24, 2026 07:31
https://go.dev/doc/effective_go#init

Co-authored-by: Benjamin Bengfort <benjamin@rotational.io>
Signed-off-by: Chris Okuda <chris@okuda.dev>
Signed-off-by: Chris Okuda <chris@rotational.io>
@chris-okuda chris-okuda merged commit 17112be into main Mar 24, 2026
3 checks passed
@chris-okuda chris-okuda deleted the chrisokuda/sc-37723/rlog branch March 24, 2026 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants