Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
maoshuai committed Dec 24, 2020
1 parent 2d76485 commit e406d78
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 115 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
**simpleLog4sh**是一个极为简单的shell日志框架,甚至不应该叫日志框架。
与其他shell日志框架不同,它仅仅是一个:

**只有几十行的纯shell脚本,没有任何依赖**
**只有几百行的纯shell脚本,没有任何依赖**

但通过简单的封装,这个小shell可以提供诸如:
1. logInfo,logDebug等多级别日志输出
2. 日志记录带有时间戳和日志级别
2. 日志记录带有时间戳和日志级别,并可控制输出日志的级别
3. 将日志输出到指定文件
4. 日志文件按日期进行归档
5. 抛出异常
6. 自动清理日志
7. 接管stdout/stederr

**simpleLog4sh**不期望做到像Apache日志框架一样复杂,仅仅在您写toy小程序的时候,能帮助你实现最简单的日志功能,而不必总是echo。

Expand All @@ -35,6 +37,11 @@ logDebug "hello, world" # 推荐将所有的内容用双引号包围
. ../src/simplelog4sh.sh
```

如果需要覆盖默认配置,可提供配置文件
```
. ../src/simpleLog4sh.source ../src/simpleLog4sh.cfg
```

## logXXX语句
simpleLog4sh提供了四个日志级别的方法,他们分别是
1. `logDebug`
Expand Down
30 changes: 19 additions & 11 deletions src/simpleLog4sh.cfg
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
# simpleLog4sh配置文件
# simpleLog4sh configuration file

# 日志文件存储的根目录(默认为/tmp/simpleLog4sh
simpleLog4sh_LOG_DIR="/tmp/simpleLog4sh-logs"
# root directory for log files (deafult: /tmp/simpleLog4sh)
# simpleLog4sh_LOG_DIR="/tmp/simpleLog4sh"

# 日志文件的前缀(默认为simpleLog4sh)
simpleLog4sh_LOG_FILE_NAME_PREFIX="simpleLog"
# prfeix name of log files (default: simpleLog4sh)
# simpleLog4sh_LOG_FILE_NAME_PREFIX="simpleLog4sh"

# 日志级别,可以设置为 ALL TRACE DEBUG INFO WARN ERROR OFF(默认为ALL)
# control the maximum number (in days) of archive files to keep (default: -1 to keep all)
# e.g. if simpleLog4sh_MAX_HISTORY=3 and today is Aug 8th, Aug 5-7th's log will be kept.
# AKA log files on and before Aug 4th will be deleted.
# If you don't want to delete old log files automatically, set as a negative number such as -1
# simpleLog4sh_MAX_HISTORY=-1

# log level: ALL TRACE DEBUG INFO WARN ERROR OFF (default: ALL)
# simpleLog4sh_LOG_LEVEL="ALL"

# 日志文件的后缀(默认为.log
# suffix name of log files (default: .log)
# simpleLog4sh_LOG_FILE_NAME_SUFFIX=".log"

# 标准输出重定向文件的后缀,空表示不重定向标准输出(默认为空)
# suffix name of stdout log (default: "")
# keep it empty if you don't want to redirect stdout
# simpleLog4sh_LOG_STDOUT_SUFFIX=".out"

# 标准错误输出重定向文件的后缀,空表示不重定向(默认为空)
# suffix name of stderr log (default: "")
# keep it empty if you don't want to redirect stderr
# simpleLog4sh_LOG_STDERR_SUFFIX=".err"

# 是否显示完成的函数调用路径(默认为false)
simpleLog4sh_LOG_FULL_CALLPATH="true"
# show full call path of functions (default: false)
# simpleLog4sh_LOG_FULL_CALLPATH="false"
Loading

0 comments on commit e406d78

Please sign in to comment.