You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
wxiaoguang 4647660776
Rewrite logger system (#24726)
## ⚠️ Breaking

The `log.<mode>.<logger>` style config has been dropped. If you used it,
please check the new config manual & app.example.ini to make your
instance output logs as expected.

Although many legacy options still work, it's encouraged to upgrade to
the new options.

The SMTP logger is deleted because SMTP is not suitable to collect logs.

If you have manually configured Gitea log options, please confirm the
logger system works as expected after upgrading.

## Description

Close #12082 and maybe more log-related issues, resolve some related
FIXMEs in old code (which seems unfixable before)

Just like rewriting queue #24505 : make code maintainable, clear legacy
bugs, and add the ability to support more writers (eg: JSON, structured
log)

There is a new document (with examples): `logging-config.en-us.md`

This PR is safer than the queue rewriting, because it's just for
logging, it won't break other logic.

## The old problems

The logging system is quite old and difficult to maintain:
* Unclear concepts: Logger, NamedLogger, MultiChannelledLogger,
SubLogger, EventLogger, WriterLogger etc
* Some code is diffuclt to konw whether it is right:
`log.DelNamedLogger("console")` vs `log.DelNamedLogger(log.DEFAULT)` vs
`log.DelLogger("console")`
* The old system heavily depends on ini config system, it's difficult to
create new logger for different purpose, and it's very fragile.
* The "color" trick is difficult to use and read, many colors are
unnecessary, and in the future structured log could help
* It's difficult to add other log formats, eg: JSON format
* The log outputer doesn't have full control of its goroutine, it's
difficult to make outputer have advanced behaviors
* The logs could be lost in some cases: eg: no Fatal error when using
CLI.
* Config options are passed by JSON, which is quite fragile.
* INI package makes the KEY in `[log]` section visible in `[log.sub1]`
and `[log.sub1.subA]`, this behavior is quite fragile and would cause
more unclear problems, and there is no strong requirement to support
`log.<mode>.<logger>` syntax.


## The new design

See `logger.go` for documents.


## Screenshot

<details>


![image](https://github.com/go-gitea/gitea/assets/2114189/4462d713-ba39-41f5-bb08-de912e67e1ff)


![image](https://github.com/go-gitea/gitea/assets/2114189/b188035e-f691-428b-8b2d-ff7b2199b2f9)


![image](https://github.com/go-gitea/gitea/assets/2114189/132e9745-1c3b-4e00-9e0d-15eaea495dee)

</details>

## TODO

* [x] add some new tests
* [x] fix some tests
* [x] test some sub-commands (manually ....)

---------

Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Giteabot <teabot@gitea.io>
1 year ago
..
foreachref Implement FSFE REUSE for golang files (#21840) 2 years ago
internal Refactor git command package to improve security and maintainability (#22678) 1 year ago
pipeline Refactor and tidy-up the merge/update branch code (#22568) 1 year ago
tests/repos Fix commit retrieval by tag (#21804) 1 year ago
url Implement FSFE REUSE for golang files (#21840) 2 years ago
README.md move code.gitea.io/git to code.gitea.io/gitea/modules/git (#6364) 5 years ago
batch_reader.go Implement FSFE REUSE for golang files (#21840) 2 years ago
blame.go Fix blame view missing lines (#22826) 1 year ago
blame_test.go Fix blame view missing lines (#22826) 1 year ago
blob.go Implement FSFE REUSE for golang files (#21840) 2 years ago
blob_gogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
blob_nogogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
blob_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
command.go Allow adding new files to an empty repo (#24164) 1 year ago
command_race_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
command_test.go Improve git log for debugging (#24095) 1 year ago
commit.go Pass 'not' to commit count (#24473) 1 year ago
commit_convert_gogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
commit_info.go Implement FSFE REUSE for golang files (#21840) 2 years ago
commit_info_gogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
commit_info_nogogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
commit_info_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
commit_reader.go Implement FSFE REUSE for golang files (#21840) 2 years ago
commit_test.go Pass 'not' to commit count (#24473) 1 year ago
diff.go Implement FSFE REUSE for golang files (#21840) 2 years ago
diff_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
error.go Implement FSFE REUSE for golang files (#21840) 2 years ago
git.go Support reflogs (#22451) 1 year ago
git_test.go Rewrite logger system (#24726) 1 year ago
hook.go Implement FSFE REUSE for golang files (#21840) 2 years ago
last_commit_cache.go Use minio/sha256-simd for accelerated SHA256 (#23052) 1 year ago
last_commit_cache_gogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
last_commit_cache_nogogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
log_name_status.go Handle files starting with colons in WalkGitLog (#22935) 1 year ago
notes.go Implement FSFE REUSE for golang files (#21840) 2 years ago
notes_gogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
notes_nogogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
notes_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
parse_gogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
parse_gogit_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
parse_nogogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
parse_nogogit_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
ref.go Util type to parse ref name (#21969) 2 years ago
remote.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo.go Faster git.GetDivergingCommits (#24482) 1 year ago
repo_archive.go Refactor git command package to improve security and maintainability (#22678) 1 year ago
repo_attribute.go Refactor legacy strange git operations (#22756) 1 year ago
repo_attribute_test.go Use more specific test methods (#24265) 1 year ago
repo_base.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo_base_gogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo_base_nogogit.go Allow adding new files to an empty repo (#24164) 1 year ago
repo_blame.go Refactor git command package to improve security and maintainability (#22678) 1 year ago
repo_blob.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo_blob_gogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo_blob_nogogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo_blob_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo_branch.go Add status indicator on main home screen for each repo (#24638) 1 year ago
repo_branch_gogit.go Refactor git command package to improve security and maintainability (#22678) 1 year ago
repo_branch_nogogit.go Refactor git command package to improve security and maintainability (#22678) 1 year ago
repo_branch_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo_commit.go Pass 'not' to commit count (#24473) 1 year ago
repo_commit_gogit.go Fix commit retrieval by tag (#21804) 1 year ago
repo_commit_nogogit.go Fix commit retrieval by tag (#21804) 1 year ago
repo_commit_test.go Use more specific test methods (#24265) 1 year ago
repo_commitgraph.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo_commitgraph_gogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo_compare.go Add git dashes separator to some "log" and "diff" commands (#23606) 1 year ago
repo_compare_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo_gpg.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo_hook.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo_index.go Use complete SHA to create and query commit status (#22244) 2 years ago
repo_language_stats.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo_language_stats_gogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo_language_stats_nogogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo_language_stats_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo_object.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo_ref.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo_ref_gogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo_ref_nogogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo_ref_test.go Fix commit retrieval by tag (#21804) 1 year ago
repo_stats.go Refactor git command package to improve security and maintainability (#22678) 1 year ago
repo_stats_test.go Fix commit retrieval by tag (#21804) 1 year ago
repo_tag.go Refactor git command package to improve security and maintainability (#22678) 1 year ago
repo_tag_gogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
repo_tag_nogogit.go Refactor git command package to improve security and maintainability (#22678) 1 year ago
repo_tag_test.go Use more specific test methods (#24265) 1 year ago
repo_test.go Faster git.GetDivergingCommits (#24482) 1 year ago
repo_tree.go Refactor git command package to improve security and maintainability (#22678) 1 year ago
repo_tree_gogit.go Use complete SHA to create and query commit status (#22244) 2 years ago
repo_tree_nogogit.go Use complete SHA to create and query commit status (#22244) 2 years ago
sha1.go Use complete SHA to create and query commit status (#22244) 2 years ago
sha1_gogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
sha1_nogogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
sha1_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
signature.go Implement FSFE REUSE for golang files (#21840) 2 years ago
signature_gogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
signature_nogogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
submodule.go Implement FSFE REUSE for golang files (#21840) 2 years ago
submodule_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
tag.go Implement FSFE REUSE for golang files (#21840) 2 years ago
tag_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
tree.go Implement FSFE REUSE for golang files (#21840) 2 years ago
tree_blob.go Implement FSFE REUSE for golang files (#21840) 2 years ago
tree_blob_gogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
tree_blob_nogogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
tree_entry.go Remember to attach the parent tree when converting TreeEntry() -> Tree() (#22902) 1 year ago
tree_entry_gogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
tree_entry_mode.go Implement FSFE REUSE for golang files (#21840) 2 years ago
tree_entry_nogogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
tree_entry_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago
tree_gogit.go Implement FSFE REUSE for golang files (#21840) 2 years ago
tree_nogogit.go Refactor git command package to improve security and maintainability (#22678) 1 year ago
utils.go Implement FSFE REUSE for golang files (#21840) 2 years ago
utils_test.go Implement FSFE REUSE for golang files (#21840) 2 years ago

README.md

Git Module

This module is merged from https://github.com/go-gitea/git which is a Go module to access Git through shell commands. Now it's a part of gitea's main repository for easier pull request.