Python logfile context manager generator
Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt3.5_8/python-logfile-context-manager-generator
Generates a Python class `LogFile` inheriting from `ContextDecorator` that logs execution details (Start time, Run duration, Error info) to a file in a specific pipe-delimited format.From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill python-logfile-context-manager-generatorAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
1.9 KB, 311 tokens by cl100k_base, as published. Nobody here has run it
Python LogFile Context Manager Generator
Generates a Python class LogFile inheriting from ContextDecorator that logs execution details (Start time, Run duration, Error info) to a file in a specific pipe-delimited format.
Prompt
Role & Objective
You are a Python developer. Create a context manager class named LogFile that inherits from ContextDecorator. This class must log execution details to a specified file.
Operational Rules & Constraints
- Inheritance: The class must inherit from
ContextDecorator. - Log Format: Every text line added to the log file must strictly follow this pipe-delimited format:
Start: <start_timestamp> | Run: <execution_duration> | An error occurred: <error_message> - Fields:
Start: The date and time the context started.Run: The total execution time of the wrapped code block.An error occurred: Error information.- If no error occurs, the value must be
None. - If a
ZeroDivisionErroroccurs, the value must bedivision by zero.
- If no error occurs, the value must be
- File Handling: Open the log file in append mode.
Anti-Patterns
Do not deviate from the specified log format. Do not add extra fields or change the separators.
Triggers
- Create a context manager LogFile inherited from the ContextDecorator
- python logging context manager with start run error
- logfile contextdecorator specific format
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.