MCPcopy Create free account
hub / github.com/SpaceZephyr/myskill / append_log

Function append_log

skill-logger/scripts/log_skill_usage.py:23–50  ·  view source on GitHub ↗
(skill, scene, satisfaction, note='')

Source from the content-addressed store, hash-verified

21
22
23def append_log(skill, scene, satisfaction, note=''):
24 now = datetime.now()
25 record = {
26 'date': now.strftime('%Y-%m-%d'),
27 'weekday': WEEKDAY_MAP[now.weekday()],
28 'week': get_week_number(now),
29 'skill': skill,
30 'scene': scene,
31 'satisfaction': int(satisfaction),
32 'note': note,
33 }
34
35 os.makedirs(os.path.dirname(LOG_FILE), exist_ok=True)
36
37 # 如果文件不存在,先写入 schema 行
38 if not os.path.exists(LOG_FILE):
39 schema = {
40 '_schema': 'skill_usage_log',
41 '_version': '1.0',
42 '_description': 'Skill 使用日志。每次使用 Skill 后追加一条记录,用于频率分析和满意度追踪。'
43 }
44 with open(LOG_FILE, 'w', encoding='utf-8') as f:
45 f.write(json.dumps(schema, ensure_ascii=False) + '\n')
46
47 with open(LOG_FILE, 'a', encoding='utf-8') as f:
48 f.write(json.dumps(record, ensure_ascii=False) + '\n')
49
50 return record
51
52
53def main():

Callers 1

mainFunction · 0.85

Calls 1

get_week_numberFunction · 0.85

Tested by

no test coverage detected