Skip to content

Commit

Permalink
Fix doc
Browse files Browse the repository at this point in the history
  • Loading branch information
limodou committed Oct 19, 2015
1 parent af49c5d commit f42616c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
4 changes: 2 additions & 2 deletions docs/zh_CN/i18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class User(Model):


{% alert class=info %}
使用lazy的函数不能支持 `_('%s') % 'name'` 这种形式,所以建议使用非lazy的函数
使用lazy的函数不能支持 `_('%s') % 'name'` 这种形式,但是可以使用 `format()` 函数,详见[格式化](#format).
{% endalert %}

### 模板
Expand Down Expand Up @@ -149,7 +149,7 @@ NAME = _('username')

## I18N字符串的特殊处理

### 格式化
### 格式化 {#format}

有时我们需要对符串进行格式化处理,如 `"%s" % 'hello'``"{}".format('hello')` ,这两种都是目前
Python支持的格式化处理方式,对于 i18n 字符串,可以使用format的形式来处理格式化,如:
Expand Down
36 changes: 32 additions & 4 deletions docs/zh_CN/log.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ uliweb.console = {'propagate':0, 'format':'format_simple'}
[LOG.Handlers]
#handler parameters example
#{'format':'format_full', 'level':'info', 'class':'logging.StreamHandler', 'arguments':()}
#{'format':'format_full', 'level':'info', 'class':'logging.StreamHandler',
# 'args':(), 'kwargs':{}}
Full = {'format':'format_full'}
Simple = {'format':'format_simple'}
Package = {'format':'format_package'}
Expand Down Expand Up @@ -166,8 +167,11 @@ class --
handler所对应的类对象。缺省为 。注意,这里加上了
模块的路径,以便可以方便导入。

arguments --
需要传入handler类进行初始化的参数,缺省为 。
args --
需要传入handler类进行初始化的位置参数。

kwargs --
需要传入handler类进行初始化的名字参数。

level --
handler的日志级别。缺省为NOTSET。
Expand All @@ -194,8 +198,10 @@ formatter。那么formatter的存在只是为了复用。你可以先定义几
不能是formatter的引用,因为它是要使用basicConfig()来处理的,而它是不接受一个
Formatter对象的。formatter的定义形式为:

```
key = value
```

> key = value
共中key为formatter的名字。

value为日志的格式串。具体定义参见 [Python的日志记录属性](http://docs.python.org/library/logging.html#logrecord-attributes)
Expand Down Expand Up @@ -302,3 +308,25 @@ sqlalchemy.engine = {'propagate':0}

有关sqlalchemy的logger信息可以参考 [Configuring Logging](http://docs.sqlalchemy.org/en/latest/core/engines.html#configuring-logging) 文档。

### 如何设置一个日志按大小切分

可以按如下方式进行配置:

```
[LOG.Loggers]
sep_audit_log = {'propagate':0, 'handlers':['sep_audit']}
[LOG.Handlers]
#handler parameters example
#{'format':'format_full', 'level':'info', 'class':'logging.StreamHandler', 'args':()}
sep_audit = {'format':'format_full', 'class':'logging.handlers.RotatingFileHandler',
'kwargs':{'filename':'sep_audit.log', 'maxBytes':10, 'backupCount':2}
}
```

使用时:

```
import logging
log = logging.getLogger('sep_audit_log')
```

0 comments on commit f42616c

Please sign in to comment.