gologf/Makefile

31 lines
1.0 KiB
Makefile
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

all: build
test: test_log test_run
build:
go build -o dist/gologf
run: build
./dist/gologf -start "START_PATTERN" -end "END_PATTERN" example.log
test_log:
@echo "生成测试日志文件"
@mkdir -p tests
@echo "2023-01-01 10:00:00 INFO Starting application" > tests/test.log
@echo "2023-01-01 10:01:00 DEBUG This is a debug message" >> tests/test.log
@echo "2023-01-01 10:02:00 START_PATTERN Important data here" >> tests/test.log
@echo "2023-01-01 10:03:00 INFO Processing data" >> tests/test.log
@echo "2023-01-01 10:04:00 END_PATTERN Data processing completed" >> tests/test.log
@echo "2023-01-01 10:05:00 INFO Application finished" >> tests/test.log
test_run: build
@echo "\n测试1: 匹配START_PATTERN到END_PATTERN之间的内容"
./dist/gologf -start "START_PATTERN" -end "END_PATTERN" tests/test.log
@echo "\n测试2: 仅匹配START_PATTERN直到文件结束"
./dist/gologf -start "DEBUG" tests/test.log
@echo "\n测试3: 没有匹配的内容"
./dist/gologf -start "NOT_EXISTING" tests/test.log
.PHONY: all test test_log test_run run