Skip to content
Back to skills

Others

ASecurity

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) 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
toolspython

Security analysis

A100/100

Pro scans all 20 files and shows the line behind each finding

Scanned February 12, 2026

npx -y skills add Alndaly/alndaly.github.io --skill others --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Others?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Others
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/alndaly-others/badge)](https://www.skillsdirectory.com/skills/alndaly-others)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
## `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.md3.2 KB
  • Clash.md7.5 KB
  • Curl.md5.8 KB
  • Docker/Dockerfile配置.md5.8 KB
  • Docker/Docker容器的使用.md2.8 KB
  • Docker/Docker容器连接.md487 B
  • Docker/Docker镜像的使用.md1.6 KB
  • Github/Actions.md2.4 KB
  • Github/Git命令行技巧.md568 B
  • Github/Git默认大小写不敏感.md23.1 KB
  • Github/forking workflow.md10.3 KB
  • Github/gitflow.md11 KB
  • Github/standard.md8 KB
  • Github/切换Git账号.md317 B
  • Github/统计代码行数.md287 B
  • MongoDB.md713 B
  • Npm/本地测试NPM包.md950 B
  • Oauth.md5.1 KB
  • Pip/index.md5.9 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.