{"id":17862910,"url":"https://github.com/dheavy/mann","last_synced_at":"2025-04-02T21:15:42.151Z","repository":{"id":148062961,"uuid":"54471025","full_name":"dheavy/mann","owner":"dheavy","description":"Multi-purpose logger and notifier for MyPleasu.re, the Pinterest for videos — codename \"M A N N\"","archived":false,"fork":false,"pushed_at":"2016-06-14T11:19:13.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-08T11:36:12.894Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dheavy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-03-22T11:51:06.000Z","updated_at":"2018-02-07T13:09:57.000Z","dependencies_parsed_at":"2023-07-04T13:00:49.653Z","dependency_job_id":null,"html_url":"https://github.com/dheavy/mann","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dheavy%2Fmann","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dheavy%2Fmann/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dheavy%2Fmann/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dheavy%2Fmann/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dheavy","download_url":"https://codeload.github.com/dheavy/mann/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246892849,"owners_count":20850850,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-28T08:56:47.610Z","updated_at":"2025-04-02T21:15:42.125Z","avatar_url":"https://github.com/dheavy.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Mann\n====\n\n### Logger and notifier util.\n\nIt both logs to console and files, and can notify these logs via emails, Slack and Trello.\n\nInstantiate it passing booleans in *args specifying\nthe logger and notifiers to use.\nUse the `log` method to log/notify.\n\nDefault were set to simplify configuration (_i.e. file logging uses RotatingFileHandler with 'ab' write mode,\nmax bytes size of 2000, a backup count of 100 and UTF-8 encoding_).\n\n- **console** - print in console if exists\n- **file**    - logs to file if exists, using provided file handlers\n- **email**   - send log via email if exists\n- **slack**   - sends Slack message if exists\n- **trello**  - create Trello task based on log, if exists\n\n```python\n**kwargs:\n{\n    'console': True,\n    'file': {\n        'info': \u003cinfo-outfile-handle\u003e,\n        'error': \u003cerror-outfile-handle\u003e,\n    },\n    'email': {\n        'server': \u003csmtp-server\u003e,\n        'port': \u003csmtp-port-defaults-to-587\u003e,\n        'sendername': \u003chuman-friendly-sender-name\u003e,\n        'from': \u003cemail-from-address\u003e,\n        'to': \u003cemail-to-address\u003e,\n        'subject': \u003csubject-line\u003e,\n        'user': \u003csmtp-user\u003e,\n        'password': \u003csmtp-password\u003e\n    },\n    'slack': {\n        'key': \u003capi-key\u003e,\n        'channel': \u003capi-channel\u003e,\n        'username': \u003cbot-name\u003e\n    },\n    'trello': {\n        'key': \u003capi-key\u003e,\n        'token': \u003coauth-token\u003e,\n        'list': '\u003clist-id\u003e',\n        'cardname': \u003coptional-card-name\u003e\n        'members': \u003cstring-id-or-tuple-of-member-ids-to-add\u003e\n    }\n}\n```\n\n## Usage\n\n#### Printing to console\n```python\nlogger = Mann(console=True)\n\n# Outputs in console \"Fendi is a good dog.\".\nlogger.log('Fendi is a good dog.')\n\n# Outputs in console \"[ERROR] Fendi is a moody dog.\".\nlogger.log('Fendi is a moody dog.', error=True)\n```\n\n#### Logging to file(s)\n```python\n# Create a log file for 'info' level.\nlogger = Mann(file={'info': 'info_file_name.log'})\n\n# Creates file 'info_file_name.log'\n# and echoes 'Loola is a nice puppy.' inside it.\nlogger.log('Loola is a nice puppy.')\n\n# Nothing happens! 'info_file_name.log' is untouched...\nlogger.log('Loola barks a lot!', error=True)\n\n# Create a log file for 'error' level.\nlogger = Mann(file={'error': 'error_file_name.log'})\n\n# Nothing happens! 'info_file_name.log' is untouched,\n# and neither is 'error_file_name.log'...\nlogger.log('Loola is a nice puppy.')\n\n# Creates file 'error_file_name.log'\n# and echoes 'Loola barks a lot!' inside it.\nlogger.log('Loola barks a lot!', error=True)\n\n# You can create both files at the same time.\n# The proper file will be written on call to 'log'\n# depending on whether 'error=True' or not.\nlogger = Mann(file={\n    'info': 'info_file_name.log',\n    'error': 'error_file_name.log'\n})\n```\n\n#### Sending log by email\n```python\nlogger = Mann(email={\n    'server': smtp.example.com,\n    'port': 587,               # optional - defaults to 587\n    'sendername': 'Loola',     # optional - defaults to ''\n    'from': 'loola@example.com',\n    'to': 'fendi@example.com',\n    'subject': 'Waff! Waff!',  # optional - defaults to ''\n    'user': 'server_username',\n    'password': 'server_username_password'\n})\n\nlogger.log('Slurp! Slurp!')\n```\n\n#### Sending log as Slack message\n\nThe message sender appears as a bot :dog:, obviously.\n\n```python\nlogger = Mann(slack={\n    'key': 'my-slack-app-key',\n    'channel': '#plougastel',    # optional - defaults to '#random'\n    'username': 'FendouilleBot'  # optional - defaults to 'Bot'\n})\n\nlogger.log('Slurp! Slurp!')\n```\n\n#### Sending log as Trello card\n\nPerfect for creating task and assigning members on it, say,\nwhen the logger bubbled up an exception (\"_Davy, go fix that bug :sob:_\").\n\nGet your **key** [here](https://trello.com/app-key) and generate your token using your key and the following URL:\n`https://trello.com/1/authorize?expiration=never\u0026scope=read,write,account\u0026response_type=token\u0026name=\u003cYOUR-APP-NAME\u003e\u0026key=\u003cYOUR-KEY\u003e`.\n\nFiddle with the [Trello Developer Sandbox](https://developers.trello.com/sandbox) and read the [API docs](https://developers.trello.com/advanced-reference/) to extract `ID`s for your `list` and `member`s.\n\n```python\nlogger = Mann(trello={\n    'key': 'trello-key',\n    'token': 'trello-token',\n    'list': 'trello-list-id',\n    'cardname': 'Please feed the dogs while I am gone.'\n    'members': 'member-id'  # optional|mixed - can be set to user id\n                            # as string or a tuple of user ids as strings\n})\n\n# Create a Trello card. The log message is set a card description,\n# and becomes the card title (name) if 'cardname' wasn't set.\n# If 'members' were added, they will be assigned to the card.\nlogger.log('The food is in the drawer. Love, mum.')\n```\n\n#### Mix it all up!\n\nYou can mix several (or all) methods to log and notify everywhere you want at once.\n\n```python\nfile = {\n    'info': 'mum_asked_politely.log',\n    'error': 'sisters_didnt_listen.log'\n}\n\nemail = {\n    'server': smtp.example.com,\n    'sendername': 'Mum',\n    'from': 'mum@example.com',\n    'to': 'sisters@example.com',\n    'subject': 'I SAID FEED THE DOGS NOW!',\n    'user': 'server_username',\n    'password': 'server_username_password'\n}\n\nslack = {\n    'key': 'my-slack-app-key',\n    'channel': '#plougastel',\n    'username': 'Mum'\n}\n\ntrello = {\n    'key': 'trello-key',\n    'token': 'trello-token',\n    'list': 'trello-list-id',\n    'cardname': 'I SAID FEED THE DOGS NOW!'\n    'members': ('marion-id', 'morgane-id')\n}\n\nlogger = Mann(\n    console=True,\n    file=file,\n    email=email,\n    slack=slack,\n    trello=trello\n)\n\nlogger.log(\n    \"Les filles, vous commencez à me plaire là... \\\n    DON'T MAKE ME COME TELL YOU FACE TO FACE OR ELSE...\"\n)\n```\n\n## License\n\n#### MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdheavy%2Fmann","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdheavy%2Fmann","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdheavy%2Fmann/lists"}