Skip to content
/ xlog Public

js log info collection and trace, show it by call show()

License

Notifications You must be signed in to change notification settings

ccjoe/xlog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XLog

XLog is a log management by PROD or DEV,

  • IN PROD Mode, just collect the log info, donot print in console
  • IN DEV Mode, console info will be show real time
  • IN CLOSE Mode, console will be not effected

Feature

  • log ui
  • log level
  • log group and sort by time
  • log find and filter
  • log show by real-time(DEV) or manual call at console(PROD)
  • error catch auto

Example

xlog example

Classes

XLog

Members

LOG

XLog - https://github.com/ccjoe/XLog

XLog

Kind: global class

new XLog(opt)

eg: var xLog = new XLog(opt)

create a XLog instance

Param Type Default Description
opt object arguments object
[opt.level] number 3 log level LOG.LEVEL below level not show auto or manual, but set() to change LEVEL
[opt.mode] string "DEV" 'CLOSE' OR 'DEV' OR 'PROD' LOG.MODE DEV mode show log realtime, PROD mode show log manual by sh
ow() method CLOSE will be all Xlog.js and error monitor
[opt.send] function function(){} if u need to send log to remote, u need to define send function

Collection Log Data(pls see: run index.html or visit test.js)

log.emergency('this is show by log.emergency')
log.alert('this is show by log.alert')
log.critical('this is show by log.critical')
log.error('this is show by log.error')
log.warn('this is show by log.warn')
log.notice('this is show by log.notice')
log.info('this is show by log.info')
log.log('this is show by log.log')

log.add(0, 'this is a 0 by log.add')
log.add(1, 'this is a 1 by log.add')
log.add(2, 'this is a 2 by log.add')
log.add(3, 'this is a 3 by log.add')
log.add(4, 'this is a 4 by log.add')
log.add(5, 'this is a 5 by log.add')
log.add(6, 'this is a 6 by log.add')
log.add(7, 'this is a 7 by log.add')

setTimeout(function () { log.add(5, 'this is a info by async') }, 200)
log.catch(test.testError)('test show')

//add try catch for all test2 modules function and test.start function
log.catchModule(test2);
log.catch(test.start)()

xLog.init()

init reset XLog data

Kind: instance method of XLog

xLog.size() ⇒ obejct

Get the size of all local log

Kind: instance method of XLog Returns: obejct - - Object {len: 2827, byte: 2903, size: 2.8349609375}

xLog.get(level) ⇒ object

Get the log data by level

Kind: instance method of XLog Returns: object - XLog.data

Param Type Description
level number | string the level Number or Name String of log item

xLog.set(level)

set log level, just show log below level number

Kind: instance method of XLog

Param Type Description
level number | string the level Number or Name String of log item

xLog.show(level, [sort])

Show All XLogs 显示所有日志信息(受限不能大于XLOG.level), 传入level则显示level: 0~number, level name则仅显示name 对应的level

Kind: instance method of XLog

Param Type Default Description
level number | string the level Number or Name String of log item
[sort] string "'time'" time or group- show log by time sorted

Example

XLOG.show()  print level 0~3 [this.level=3]
XLOG.show(0)  print level 0
XLOG.show(1)  print level 0-1
XLOG.show(n)  print level 0-n, n max is 7
XLOG.show('EMERGENCY') optional ['ALERT','CRITICAL','ERROR','WARN','NOTICE','INFO','LOG'] print corresponding level

xLog.find(str, level)

Show and Print the log info by str or level

Kind: instance method of XLog

Param Type Description
str string find log by str, find log by console, level,stack info, etc...
level number | string the level Number or Name String of log item find, if null no level limited

xLog.reset(level)

reset log data 重置所有日志内容

Kind: instance method of XLog

Param Type Description
level number | string the level Number or Name String of log item

xLog.catch(f) ⇒ function

decorate function f with try catch wrapper

Kind: instance method of XLog Returns: function - f - return try catch wrappered f

Param Type
f function

xLog.catchModule(m)

decorate every function of module m with try catch wrapper

Kind: instance method of XLog

Param Type Description
m object module with functions

XLog.LOG : enum

XLog.LOG.LEVELHE LOG

Kind: static enum of XLog Example

0: 'EMERGENCY',  //system unusable
1: 'ALERT',      //immediate action required
2: 'CRITICAL',   //condition critical
3: 'ERROR',      //condition error
4: 'WARN',       //condition warning
5: 'NOTICE',     //condition normal, but significant
6: 'INFO',       //a purely informational message
7: 'LOG'         // LOG or debugging information

LOG

XLog - https://github.com/ccjoe/XLog

Kind: global variable

Licensed under the MIT license.

About

js log info collection and trace, show it by call show()

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published