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

Logger no longer works with dictionaries #128

Closed
tkevinbest opened this issue Oct 12, 2023 · 1 comment
Closed

Logger no longer works with dictionaries #128

tkevinbest opened this issue Oct 12, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@tkevinbest
Copy link
Member

It is helpful to allow the logger to work with dictionaries as well as objects. This lets you use the locals() function to get a dictionary of all local values.

This version of the logger allows it:

def update(self, dataContainersIn):
        if self.save:
            row = []
            for (varGroup, container) in zip(self.varNames, dataContainersIn):
                if type(container) is dict:
                    for var in varGroup:
                        row.append(container.get(var))
                else:
                    for var in varGroup:
                        row.append(getattr(container, var))
            self.csv_writer.writerow(row)

I wanted to use this syntax and was unable to: osl.log.add_attributes(locals(), ["active_test_conditions"])

@tkevinbest tkevinbest added the bug Something isn't working label Oct 12, 2023
@senthurayyappan
Copy link
Member

Added support for dict containers! Please checkout the dev branch [34905af].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants