Skip to content
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

Add event emitter #5

Merged
merged 14 commits into from
Jul 14, 2024
Merged

Add event emitter #5

merged 14 commits into from
Jul 14, 2024

Conversation

ptesavol
Copy link
Collaborator

  • Add streamr-eventemitter package

@ptesavol ptesavol changed the base branch from main to module1 June 18, 2024 19:08
@ptesavol ptesavol marked this pull request as ready for review June 20, 2024 02:31
Copy link
Collaborator

@SanttuRantanen SanttuRantanen left a comment

Choose a reason for hiding this comment

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

I reviewed the code and gave some comments. It looks good anyway.

@ptesavol ptesavol merged commit 6f0251a into module1 Jul 14, 2024
3 checks passed
ptesavol added a commit that referenced this pull request Aug 15, 2024
* create directory structure

* working empty monorepo

* add build instructions to readme

* also clean the main build folder

* add CONFIG flag to folly find_package

* it builds

* rename build.sh to install.sh so build.sh can be the name for the normal build scripts

* add testing scripts

* lint works in sub-projects

* update README

* updated tooling

* updated prerequisities script

* enable linting

* remove automatic pre-commit formatting

* add pre-commit checking

* get runk to work with clangd-tidy

* improve testing setup

* added ci workflows

* WP1

Implement  WP1 requirements:
* monorepo
* installation
* build environment
* linting
* testing
* CI

* Add streamr-json package (#2)

* testing ci

* fix ci

* fix ci

* fix ci

* fix ci

* fix ci

* fix ci

* fix ci

* fix ci

* fix ci

* fix ci

* fix ci

* fix ci

* ci

* ci

* set trunk branch

* set trunk branch

* set trunk branch

* fetch all from git

* fix linting

* fix clangd config

* add clangd apt install

* do ci in single action

* report test failure in ci

* remove failing test

* fix test script

* add package streamr-json that provides toJson(any) and toString(any) helper functions

* chore: set script as executable (a+x)

* Revert "chore: set script as executable (a+x)"

This reverts commit 85f61c6.

Closer reading revealed that .sh file isn't meant to be run but sourced

* Improve streamr json and enable transitive monorepo dependencies (#4)

* testing ci

* fix ci

* fix ci

* fix ci

* fix ci

* fix ci

* fix ci

* fix ci

* fix ci

* fix ci

* fix ci

* fix ci

* fix ci

* ci

* ci

* set trunk branch

* set trunk branch

* set trunk branch

* fetch all from git

* fix linting

* fix clangd config

* add clangd apt install

* do ci in single action

* report test failure in ci

* remove failing test

* fix test script

* add package streamr-json that provides toJson(any) and toString(any) helper functions

* improve streamr-json to allow initializer lists with structs, make transitive monorepo dependencies work

* fix ci build, try vcpkg.json as cache hash

* fix format

* fix formatting

* remove commented code, add comment on how JsonBuilder works

* fix formatting

* use latest homebrew clang on mac, create setenvs.sh  (#6)

* use latest homebrew clang on mac, create setenvs.sh file in install-prerequisities

* create setenvs.sh file if it does not exist

* Add basic logger (#3)

* StreamrFormatter is ready for implementation

* Output of StreamrFormatter is now in format like this: INFO [2024-06-06T14:29:36] (Logger.hpp): dddkdkdkkdkdkdkdkdkd

* Fixed size filename and linenumber added (Including filename truncate). Colors added to LogLevels)

* logDebug level fixed

* formatMessageInStreamrStyle added. It is easier to unit test with it

* StreamrFormatterTest template added

* Correct colors included

* Message color added

* StreamrLogFormatterTest tests added

* SLOG_TRACE, SLOG_DEBUG... macros added. They work with lazy init so that the Logger class is not needed to create explicitly

* Little bit cleaning

* Bit cleaning

* Folly root log level added. Also now Folly log C++ API is called directly instead of macros.

* getFollyLogLevelFromEnv added

* Folly root log level updated only if env different

* New tests added

* Cleanup

* Unit testing

* Added bit comments

* Added bit comments

* Unit Tests done

* Unit Tests done

* Unit Tests done

* some fix

* Classes split to different files

* Streamr enum classes added to protect the API for invalid values

* Formatter Log level data mapping changed to switch

* Formatter string changed

* Some cleaning

* temp commit

* temp commit

* temp commit

* log functions as templates

* log functions as templates

* log functions as templates

* fix lint formatting issues

* Fixed issue with constant initialization

* Fixed issue with constant initialization

* LogFormatter strings fixed

* LogFormatter tests changed to regex check to avoid timezone issues

* One unused member variable deleted.

* log meta data requires the concept type TypeWithToString

* include dir changed

* include dir changed

* TypeWithToString added to the context binding contructor argument. And const refs added to metadatas.

* Merge functionality added to concept bindings and metadata.

* Consts added to function parameters.

* Maps changed to constexpr functions and code updated based on review comments.

* Memset removed.

* CMake change.

* CMake change

* Context bindings name changed

* Linux merge issue fixed

* One comment removed

* fix build by adding namespace streamr:: when linking against other monorepo packages

* Macros added back because it is only way to get filename and lininumber

* Constructor parameters changed to have default values.

* Removed Lint complains from a test file.

* Changed based on lint comments.

* A couple of merge unit tests added.

* Member variables changed to the naming convention mVarName

* source_location is used instead of macros.

* Mock output removed

* Log overloading functions not needed

* Mock output removed.

* move mapping between streamr and folly log levels to a compile-time map

* simplify contexBinding handling, add colors to test output

* return folly::loglevel::INFO if log level mapping is not found

* remove constexpr from getLogLevelMap(), gcc does not allow setting statics in constexpr functions

* Enable per-filename loglevels, create LoggerImpl interface, move all Folly-specific things to detail/

* move all log level naming, colors to StreamrLogeLevel.hpp and access the information through LogLevelMap.hpp

* clean up StreamrLogFormatter.hpp

* move std::visit() usage to a helper function

* Add magic static instance() method to allow singleton-like usage

* only read LOG_LEVEL env variable in Logger constructor

* add example to streamr-logger

* fix LoggerExample to work

* add support for struct-containing json in contextBindings

* rework env variables handling

* add README.md and use different log levels in example

* prioritize category log level over the default log level

* use HOMEBREW_PREFIX env variable to find the actual homebrew installation

* Log Category tests added

* A bit of cleaning

* One test added to category log level

* remove using namespace statement according to reviewer comments

---------

Co-authored-by: Petri Savolainen <[email protected]>

* Add event emitter (#5)

* add first incomplete version of EventEmitter

* fix formatting

* add safety features: prevent adding null handlers, prevent adding same handler more than once

* test anomaly: empty lambdas seem to get the same address in g++?

* use HandlerReferences in off() because function pointers cannot be reliably compared

* add code comments

* fix formatting

* use concepts MatchingEventType and MatchingCallbackType

* make all EventEmitter operations synchronized with mutex

* follow naming convention mMyVar for member variables

* use size_t, change folding expressions link

* fix formatting

* lock emitting loop of EventEmitterImpl with a mutex and add a test that shows why this is necessary

* Install troubleshooting (#7)

* doc: troubleshooting tips

* doc: troubleshoot clangd version messing up linting

* fix typo

---------

Co-authored-by: Petri Savolainen <[email protected]>

* Improve streamr-json documentation (#8)

* add StreamrJsonInitializerList type alias

* add streamr-json example

* remove commented code

* Add Implementation details section to README.md

* Module1 review response: add example of emitting an event in README.md

* Module1 review response: disable the need for NOLINT in gtest protected class members

* Module1 review response: move forced linting from pre-commit to pre-push hook

* add nolint to extern environ declaration

* Module1 Review response: introduce static SLogger (#10)

* Logger with static functions added

* SLogger description added

* SLogger function comments added

* remove separate slogger target

---------
authored-by: Santtu <[email protected]>

* Module1 review response: add IDE and extension recommendations to readme

* Module1 review response: add --prod parameter to install.sh to configure  in production mode

---------

Co-authored-by: Juuso Takalainen <[email protected]>
Co-authored-by: SanttuRantanen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants