
Research
PyPI Package Disguised as Instagram Growth Tool Harvests User Credentials
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
github.com/ibbd-dev/go-async-log
go get -u github.com/ibbd-dev/go-async-log
RFC3339
,格式如2006-01-02T15:04:05Z07:00
普通写入日志文件
lf := asyncLog.NewLogFile("/tmp/test.log")
// 设置按天切割文件,如果默认则是按小时
lf.SetRotate(asyncLog.RotateDate)
lf.SetProbability(0.5) // 设置写log的概率,默认全部都写入
_ = lf.Write("lf: hello world")
// 注意:因为是每秒写入一次,所以这里需要暂停一下
time.Sleep(time.Second * 2)
写入错误等级文件
infoFile := asyncLog.NewLevelLog("/tmp/test-info.log", asyncLog.LevelInfo) // 只有Info级别或者以上级别的日志才会被记录
infoFile.SetProbability(0.5) // 设置写log的概率,默认全部都写入
infoFile.Debug("hello world") // 该日志不会写入文件
infoFile.Info("hello world")
infoFile.Error("hello world")
// 需要改变日志写入等级时,例如测试阶段
infoFile.SetLevel(asyncLog.LevelDebug)
time.Sleep(time.Second * 2)
不缓存内容的时候,如果不对文件句柄进行缓存重用,性能是比较低的,如下:(这是旧版本)
# go test -bench=".*"
BenchmarkWrite-4 3000000 444 ns/op
BenchmarkWriteNoCache-4 300000 4400 ns/op
对句柄进行缓存重用之后,性能如下:
BenchmarkWrite-4 3000000 570 ns/op
BenchmarkWriteNoCache-4 1000000 2304 ns/op
结论:对句柄进行缓存,是能大大提升效率的。
性能比github.com/ibbd-dev/go-tools/logfile
至少提升一个数量级
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.