Back to skills
SKILL.md
Others
ASecurityif(not os.path.exists(os.path.abspath('./logs'))): os.mkdir(os.path.abspath('./logs')) self.logger = logging.getLogger(logger) self.fmt=logging.Formatter('%(asctime)s - %(name)s - %(levelname)s -%(message)s ') logging.root.setLevel(logging.NOTSET) def getlog(self): ch=logging.StreamHandler() fh = logging.handlers.RotatingFileHandler(os.path.abspath('./logs/test.log'), maxBytes=20000, backupCount=5) ch.setFormatter(self.fmt) fh.setFormatter(self.fmt) ch.setLevel(logging.INFO) fh.setLevel(loggi...
- 2 stars
- 0 votes
- 0 copies
- 1 view
- Added February 6, 2026
Security analysis
100/100Pro scans all 20 files and shows the line behind each finding
npx -y skills add Alndaly/alndaly.github.io --skill others --agent claude-codeAre you the author of Others?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/alndaly-others)## `logging`模块的基层level无法覆盖问题
```python {12}
import logging
from logging.handlers import QueueHandler
import os
class MyLogger(object):
def __init__(self,logger):
# 判断是否存在log文件夹,如果不存在则创建
if(not os.path.exists(os.path.abspath('./logs'))):
os.mkdir(os.path.abspath('./logs'))
self.logger = logging.getLogger(logger)
self.fmt=logging.Formatter('%(asctime)s - %(name)s - %(levelname)s -%(message)s ')
logging.root.setLevel(logging.NOTSET)
#logging.basicConfig(level=logging.NOTSET)
def getlog(self):
ch=logging.StreamHandler()
fh = logging.handlers.RotatingFileHandler(os.path.abspath('./logs/test.log'), maxBytes=20000, backupCount=5)
ch.setFormatter(self.fmt)
fh.setFormatter(self.fmt)
ch.setLevel(logging.INFO)
fh.setLevel(logging.INFO)
self.logger.addHandler(ch)
self.logger.addHandler(fh)
return self.logger
```
:::note
`from logging.handlers import QueueHandler`这一行是为了引入`logging.handlers`,避免下文中的`logging.handlers.RotatingFileHandler`报错。
:::
## 获取当前文件绝对路径
```python
from pathlib import Path
import os
BASE_DIR = Path(__file__).resolve()
```
## 获取父级的父级的目录文件绝对路径
```python
from pathlib import Path
import os
BASE_DIR = Path(__file__).resolve().parent.parent
```Files in this skill
- Anaconda/basic-utils.md
- Clash.md
- Curl.md
- Docker/Dockerfile配置.md
- Docker/Docker容器的使用.md
- Docker/Docker容器连接.md
- Docker/Docker镜像的使用.md
- Github/Actions.md
- Github/Git命令行技巧.md
- Github/Git默认大小写不敏感.md
- Github/forking workflow.md
- Github/gitflow.md
- Github/standard.md
- Github/切换Git账号.md
- Github/统计代码行数.md
- MongoDB.md
- Npm/本地测试NPM包.md
- Oauth.md
- Pip/index.md
Attribution
Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.