[go: nahoru, domu]

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

Mandatory fields for logs and position #12

Merged
merged 2 commits into from
Dec 11, 2020
Merged

Conversation

dignajar
Copy link
Owner

Example for TEXT format.

2020-12-11 11:55:55 - INFO - Cache - 127.0.0.1 - None - User not found in the cache. - xxxxx
2020-12-11 11:55:55 - INFO - Aldap - 127.0.0.1 - None - Authenticating user. - xxxxx - xxxxx@xxx.com
2020-12-11 11:55:55 - INFO - Aldap - 127.0.0.1 - None - There was an error trying to bind.

Example for JSON format.

{"date": "2020-12-11 11:58:49", "level": "INFO", "objectName": "Cache", "ip": "127.0.0.1", "referrer": null, "message": "User not found in the cache.", "username": "xxxxx"}
{"date": "2020-12-11 11:58:49", "level": "INFO", "objectName": "Aldap", "ip": "127.0.0.1", "referrer": null, "message": "Authenticating user.", "username": "xxxxx", "finalUsername": "xxxxx@xxxxx.com"}
{"date": "2020-12-11 11:58:49", "level": "INFO", "objectName": "Aldap", "ip": "127.0.0.1", "referrer": null, "message": "There was an error trying to bind."}

files/logs.py Outdated
except Exception as e:
pass

# Merge dictionaries
mandatoryFields.update(fields)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would do something like
allFields = mandatoryFields.update(fields)

otherwise when you keep reading the code bellow it seems you only print the mandatoryFields, you have to read above to realize that at that point mandatoryFields contains all the fields

files/logs.py Outdated
if self.format == 'JSON':
print(json.dumps(fields))
print(json.dumps(mandatoryFields))
Copy link
Collaborator

Choose a reason for hiding this comment

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

then here you do
print(json.dumps(allFields))

files/logs.py Outdated
else:
print(" - ".join(fields.values()))
print(' - '.join(map(str, mandatoryFields.values())))
Copy link
Collaborator

Choose a reason for hiding this comment

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

print(' - '.join(map(str, allFields.values())))

@dignajar dignajar merged commit c3b3313 into master Dec 11, 2020
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.

None yet

2 participants