Skip to content

Commit

Permalink
[免测]增加 log 模块 (#473)
Browse files Browse the repository at this point in the history
* 增加 log 模块

* 都改成箭头函数
  • Loading branch information
PengXing authored and chenqiushi committed Jan 15, 2019
1 parent d2695ec commit 8be9ea4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/mip/examples/mip1/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,8 @@
line-height: 1.8;
word-wrap: break-word;
color: #333;
font-family: -apple-system, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", STHeiti, "Microsoft YaHei", "Microsoft JhengHei", "Source Han Sans SC", SimSun, sans-serif text-align: left
font-family: -apple-system, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", STHeiti, "Microsoft YaHei", "Microsoft JhengHei", "Source Han Sans SC", SimSun, sans-serif;
text-align: left
}

@media screen and (max-width:767px) {
Expand Down
7 changes: 5 additions & 2 deletions packages/mip/src/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import customStorage from './custom-storage'
import jsonParse from './json-parse'
import templates from './templates'
import Deferred from './deferred'
import log from './log'

/**
* Exchange a url to cache url.
Expand Down Expand Up @@ -128,7 +129,8 @@ export {
dom,
event,
templates,
Deferred
Deferred,
log
}

export default {
Expand All @@ -149,5 +151,6 @@ export default {
naboo,
jsonParse,
templates,
Deferred
Deferred,
log
}
14 changes: 14 additions & 0 deletions packages/mip/src/util/log.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

const LIST = ['info', 'log', 'warn', 'error']

class Log {
constructor (name) {
LIST.forEach(item => {
this[item] = log => {
console[item](`[${name}] ${log}`)
}
})
}
}

export default name => new Log(name)

0 comments on commit 8be9ea4

Please sign in to comment.