-
-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathcom_Log.js
More file actions
105 lines (97 loc) · 3.29 KB
/
com_Log.js
File metadata and controls
105 lines (97 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
* Project Name : Visual Python
* Description : GUI-based Python code generator
* File Name : com_Log.js
* Author : Black Logic
* Note : Log control
* License : GNU GPLv3 with Visual Python special exception
* Date : 2021. 09. 13
* Change Date :
*/
//============================================================================
// Load extension
//============================================================================
define([
'./com_Config'
], function(com_Config) {
'use strict';
//========================================================================
// Define Inner Variable
//========================================================================
/**
* Type of log
* DEVELOP 0 : log for developing/testing. if mode
*/
const _LOG_TYPE = {
ERROR : -1,
DEVELOP : 0,
LOG : 1,
WARN : 4
}
/**
* Log label
*/
const _LOG_LABEL = {
[_LOG_TYPE.DEVELOP] : 'VP_Test',
[_LOG_TYPE.LOG] : 'VP_Log',
[_LOG_TYPE.ERROR] : 'VP_ERROR',
[_LOG_TYPE.WARN] : 'VP_WARN'
}
//========================================================================
// Declare Class
//========================================================================
/**
* Log util class
*/
class Log {
//========================================================================
// Constructor
//========================================================================
constructor() {
this.currentMode = com_Config.serverMode;
}
//========================================================================
// Internal call function
//========================================================================
/**
* Get current mode
*/
get _mode() {
return this.currentMode;
}
//========================================================================
// External call function
//========================================================================
/**
* Display logs
* @param {Log.LOG_TYPE} logType Log type : DEVELOP 0/LOG 1/ERROR -1
* @param {String} displayArgs Log string text
*/
display(logType, ...displayArgs) {
// on RELEASE mode, do not show develop/test logs
if (this._mode == com_Config.MODE_TYPE.RELEASE) {
if (logType == _LOG_TYPE.DEVELOP) {
return;
}
}
if (displayArgs.length == 1) {
console.log('[' + _LOG_LABEL[logType] + ']', displayArgs[0]);
} else {
console.log('[' + _LOG_LABEL[logType] + ']', displayArgs);
}
}
}
//========================================================================
// Define Static Variable
//========================================================================
/**
* Type of log
* DEVELOP 0 : log for developing/testing. if mode
*/
Log.LOG_TYPE = _LOG_TYPE;
/**
* Log label
*/
Log.LOG_LABEL = _LOG_LABEL;
return Log;
});