Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
N
nisanci
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Ali GOREN
nisanci
Commits
9460aaf3
Unverified
Kaydet (Commit)
9460aaf3
authored
May 14, 2019
tarafından
Ali GOREN
Kaydeden (comit)
GitHub
May 14, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge pull request #3 from aligoren/dev
Colors added, debug in todo
üst
d7d297a0
7a3e9bed
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
78 additions
and
18 deletions
+78
-18
package-lock.json
package-lock.json
+0
-0
package.json
package.json
+1
-0
Colors.ts
src/Colors.ts
+50
-0
ServerException.ts
src/Exceptions/ServerException.ts
+4
-0
Logger.ts
src/Logger.ts
+23
-18
No files found.
package-lock.json
Dosyayı görüntüle @
9460aaf3
This diff is collapsed.
Click to expand it.
package.json
Dosyayı görüntüle @
9460aaf3
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
"scripts"
:
{
"scripts"
:
{
"build"
:
"tsc"
,
"build"
:
"tsc"
,
"dev"
:
"node tests/index.js"
,
"dev"
:
"node tests/index.js"
,
"doc"
:
"esdoc"
,
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
},
"keywords"
:
[
"keywords"
:
[
...
...
src/Colors.ts
0 → 100644
Dosyayı görüntüle @
9460aaf3
// reference: https://stackoverflow.com/questions/9781218/how-to-change-node-jss-console-font-color
/**
* This colors only works on Node Runtime
*/
const
nodeColors
=
{
Reset
:
"
\
x1b[0m"
,
Bright
:
"
\
x1b[1m"
,
Dim
:
"
\
x1b[2m"
,
Underscore
:
"
\
x1b[4m"
,
Blink
:
"
\
x1b[5m"
,
Reverse
:
"
\
x1b[7m"
,
Hidden
:
"
\
x1b[8m"
,
FgBlack
:
"
\
x1b[30m"
,
FgRed
:
"
\
x1b[31m"
,
FgGreen
:
"
\
x1b[32m"
,
FgYellow
:
"
\
x1b[33m"
,
FgBlue
:
"
\
x1b[34m"
,
FgMagenta
:
"
\
x1b[35m"
,
FgCyan
:
"
\
x1b[36m"
,
FgWhite
:
"
\
x1b[37m"
,
BgBlack
:
"
\
x1b[40m"
,
BgRed
:
"
\
x1b[41m"
,
BgGreen
:
"
\
x1b[42m"
,
BgYellow
:
"
\
x1b[43m"
,
BgBlue
:
"
\
x1b[44m"
,
BgMagenta
:
"
\
x1b[45m"
,
BgCyan
:
"
\
x1b[46m"
,
BgWhite
:
"
\
x1b[47m"
,
}
class
Colors
{
/**
*
* @param type - Type web or node
*/
static
GET
(
type
:
string
)
{
if
(
type
==
"node"
)
{
return
nodeColors
}
else
{
}
}
}
export
default
Colors
\ No newline at end of file
src/Exceptions/ServerException.ts
Dosyayı görüntüle @
9460aaf3
/**
* @description If the server config is wrong like endPoint, this exception will fire.
* @class ServerException
*/
class
ServerException
extends
Error
{
class
ServerException
extends
Error
{
constructor
(
message
)
{
constructor
(
message
)
{
super
();
super
();
...
...
src/Logger.ts
Dosyayı görüntüle @
9460aaf3
import
LogTypes
,
{
Levels
}
from
'./LogTypes'
import
LogTypes
,
{
Levels
}
from
'./LogTypes'
import
LogServer
from
'./LogServer'
import
LogServer
from
'./LogServer'
import
Colors
from
'./Colors'
/**
/**
* @description Logger class. This class will have logging functions
* @description Logger class. This class will have logging functions
...
@@ -26,7 +27,7 @@ class Logger {
...
@@ -26,7 +27,7 @@ class Logger {
/**
/**
* @description Send extra fields to the log backend
* @description Send extra fields to the log backend
* @function send
* @function send
* @param sendBody Extra body field
* @param sendBody
-
Extra body field
* @example
* @example
* loggerInstance.send({ pageUrl: 'test', 'time': '12:30' })
* loggerInstance.send({ pageUrl: 'test', 'time': '12:30' })
*/
*/
...
@@ -37,24 +38,28 @@ class Logger {
...
@@ -37,24 +38,28 @@ class Logger {
/**
/**
* @description Debug Level Message
* @description Debug Level Message
* @function debug
* @function debug
* @param message any type of message
* @param message
-
any type of message
* @param context Context will use to handle params. For example user IP address, username etc.
* @param context
-
Context will use to handle params. For example user IP address, username etc.
* @example
* @example
* loggerInstance.debug('Debug User', { username: 'John' })
* loggerInstance.debug('Debug User', { username: 'John' })
*/
*/
debug
(
message
:
string
,
context
:
any
)
{
debug
(
message
:
string
,
context
:
any
)
{
const
logCode
=
LogTypes
.
DEBUG
const
logCode
=
LogTypes
.
DEBUG
const
levelName
=
Levels
.
GET
(
logCode
)
const
levelName
=
Levels
.
GET
(
logCode
)
const
colors
=
Colors
.
GET
(
'node'
)
/**
* @todo This section will change. This needs formatted output
*/
console
.
log
(
logCode
,
levelName
)
console
.
log
(
logCode
,
levelName
)
console
.
log
(
`
${
colors
.
FgWhite
}${
colors
.
BgRed
}
%s`
,
`
${
levelName
}
`
,
colors
.
Reset
,
'-'
,
message
);
}
}
/**
/**
* @description Informational messages
* @description Informational messages
* @function info
* @function info
* @param message any type of message
* @param message
-
any type of message
* @param context Context will use to handle params. For example user IP address, username etc.
* @param context
-
Context will use to handle params. For example user IP address, username etc.
* @example
* @example
* loggerInstance.info('Info User', { username: 'John' })
* loggerInstance.info('Info User', { username: 'John' })
*/
*/
...
@@ -69,8 +74,8 @@ class Logger {
...
@@ -69,8 +74,8 @@ class Logger {
/**
/**
* @description Normal but significant condition
* @description Normal but significant condition
* @function notice
* @function notice
* @param message any type of message
* @param message
-
any type of message
* @param context Context will use to handle params. For example user IP address, username etc.
* @param context
-
Context will use to handle params. For example user IP address, username etc.
* @example
* @example
* loggerInstance.notice('Notice User', { username: 'John' })
* loggerInstance.notice('Notice User', { username: 'John' })
*/
*/
...
@@ -85,8 +90,8 @@ class Logger {
...
@@ -85,8 +90,8 @@ class Logger {
/**
/**
* @description You can use to show deprecated messages, old API or functions
* @description You can use to show deprecated messages, old API or functions
* @function warning
* @function warning
* @param message any type of message
* @param message
-
any type of message
* @param context Context will use to handle params. For example user IP address, username etc.
* @param context
-
Context will use to handle params. For example user IP address, username etc.
* @example
* @example
* loggerInstance.warning('Warning User', { username: 'John' })
* loggerInstance.warning('Warning User', { username: 'John' })
*/
*/
...
@@ -101,8 +106,8 @@ class Logger {
...
@@ -101,8 +106,8 @@ class Logger {
/**
/**
* @description Runtime errors, for example when parseInt or toFixed errors work wrong
* @description Runtime errors, for example when parseInt or toFixed errors work wrong
* @function error
* @function error
* @param message any type of message
* @param message
-
any type of message
* @param context Context will use to handle params. For example user IP address, username etc.
* @param context
-
Context will use to handle params. For example user IP address, username etc.
* @example
* @example
* loggerInstance.error('Error User', { username: 'John' })
* loggerInstance.error('Error User', { username: 'John' })
*/
*/
...
@@ -117,8 +122,8 @@ class Logger {
...
@@ -117,8 +122,8 @@ class Logger {
/**
/**
* @description Components unavailable or unexpected exceptions
* @description Components unavailable or unexpected exceptions
* @function critical
* @function critical
* @param message any type of message
* @param message
-
any type of message
* @param context Context will use to handle params. For example user IP address, username etc.
* @param context
-
Context will use to handle params. For example user IP address, username etc.
* @example
* @example
* loggerInstance.critical('Critical message User', { username: 'John' })
* loggerInstance.critical('Critical message User', { username: 'John' })
*/
*/
...
@@ -133,8 +138,8 @@ class Logger {
...
@@ -133,8 +138,8 @@ class Logger {
/**
/**
* @description Action must be taken immediately.
* @description Action must be taken immediately.
* @function alert
* @function alert
* @param message any type of message
* @param message
-
any type of message
* @param context Context will use to handle params. For example user IP address, username etc.
* @param context
-
Context will use to handle params. For example user IP address, username etc.
* @example
* @example
* loggerInstance.alert('Alert message User', { username: 'John' })
* loggerInstance.alert('Alert message User', { username: 'John' })
*/
*/
...
@@ -149,8 +154,8 @@ class Logger {
...
@@ -149,8 +154,8 @@ class Logger {
/**
/**
* @description System is unusable
* @description System is unusable
* @function emergency
* @function emergency
* @param message any type of message
* @param message
-
any type of message
* @param context Context will use to handle params. For example user IP address, username etc.
* @param context
-
Context will use to handle params. For example user IP address, username etc.
* @example
* @example
* loggerInstance.emergency('Emergency message User', { username: 'John' })
* loggerInstance.emergency('Emergency message User', { username: 'John' })
*/
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment