OSDN Git Service

e566f9565be1214d5698118221e16b65d5a96993
[pettanr/clientJs.git] / 0.6.x / js / 01_core / 10_XLogger.js
1 X.Notification = {\r
2         _$LogArea : null,\r
3         debug : function( msg ){\r
4                 X.Notification._output( msg, 0 );\r
5         },\r
6         info : function( msg ){\r
7                 X.Notification._output( msg, 1 );\r
8         },\r
9         warn : function( msg ){\r
10                 X.Notification._output( msg, 2 );\r
11         },\r
12         critical : function( msg ){\r
13                 X.Notification._output( msg, 3 );\r
14         },\r
15         _output : function( msg, level ){\r
16                 var body, $Area;\r
17                 if( X.Dom && X.Dom.ready === true ){\r
18                         if( $Area = X.Notification._$LogArea ){\r
19                                 $Area.remove();\r
20                                 delete X.Notification._$LogArea;\r
21                         };\r
22                         \r
23                         \r
24                 } else\r
25                 if( X.Dom && X.Dom.ready === true ){\r
26                         if( !( $Area = X.Notification._$LogArea ) ){\r
27                                 $Area = X.Notification._$LogArea = X.Dom.Node( 'div' ).addToRoot( 0 );\r
28                         };\r
29                         $Area.add( '<p>' + msg + '</p>' );\r
30                 } else          \r
31                 if( console ){\r
32                         level === 0 ? console.debug( msg ) :\r
33                         level === 1 ? console.info( msg ) :\r
34                         level === 2 ? console.warn( msg ) :\r
35                         level === 3 ? console.warn( msg ) : console.warn( msg );\r
36                 } else {\r
37                         1 < level && alert( msg );\r
38                 };\r
39         }\r
40 };\r
41 /*DEBUG、INFO、WARN、CRITICAL\r
42 emerg   サーバが稼動できないほどの重大なエラー\r
43 alert   critよりも重大なエラー\r
44 crit    重大なエラー\r
45 error   エラー\r
46 warn    警告\r
47 notice  通知メッセージ\r
48 info    サーバ情報\r
49 debug   デバック用の情報\r
50 */\r
51 \r
52 console.log( 'X.Core.Notification' );\r