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
7a3e9bed
Kaydet (Commit)
7a3e9bed
authored
May 14, 2019
tarafından
Ali
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Colors added, debug in todo
üst
a4312db6
Expand all
Hide 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 @
7a3e9bed
This diff is collapsed.
Click to expand it.
package.json
Dosyayı görüntüle @
7a3e9bed
...
...
@@ -6,6 +6,7 @@
"scripts"
:
{
"build"
:
"tsc"
,
"dev"
:
"node tests/index.js"
,
"doc"
:
"esdoc"
,
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"keywords"
:
[
...
...
src/Colors.ts
0 → 100644
Dosyayı görüntüle @
7a3e9bed
// 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 @
7a3e9bed
/**
* @description If the server config is wrong like endPoint, this exception will fire.
* @class ServerException
*/
class
ServerException
extends
Error
{
constructor
(
message
)
{
super
();
...
...
src/Logger.ts
Dosyayı görüntüle @
7a3e9bed
import
LogTypes
,
{
Levels
}
from
'./LogTypes'
import
LogServer
from
'./LogServer'
import
Colors
from
'./Colors'
/**
* @description Logger class. This class will have logging functions
...
...
@@ -26,7 +27,7 @@ class Logger {
/**
* @description Send extra fields to the log backend
* @function send
* @param sendBody Extra body field
* @param sendBody
-
Extra body field
* @example
* loggerInstance.send({ pageUrl: 'test', 'time': '12:30' })
*/
...
...
@@ -37,24 +38,28 @@ class Logger {
/**
* @description Debug Level Message
* @function debug
* @param message any type of message
* @param context Context will use to handle params. For example user IP address, username etc.
* @param message
-
any type of message
* @param context
-
Context will use to handle params. For example user IP address, username etc.
* @example
* loggerInstance.debug('Debug User', { username: 'John' })
*/
debug
(
message
:
string
,
context
:
any
)
{
const
logCode
=
LogTypes
.
DEBUG
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
(
`
${
colors
.
FgWhite
}${
colors
.
BgRed
}
%s`
,
`
${
levelName
}
`
,
colors
.
Reset
,
'-'
,
message
);
}
/**
* @description Informational messages
* @function info
* @param message any type of message
* @param context Context will use to handle params. For example user IP address, username etc.
* @param message
-
any type of message
* @param context
-
Context will use to handle params. For example user IP address, username etc.
* @example
* loggerInstance.info('Info User', { username: 'John' })
*/
...
...
@@ -69,8 +74,8 @@ class Logger {
/**
* @description Normal but significant condition
* @function notice
* @param message any type of message
* @param context Context will use to handle params. For example user IP address, username etc.
* @param message
-
any type of message
* @param context
-
Context will use to handle params. For example user IP address, username etc.
* @example
* loggerInstance.notice('Notice User', { username: 'John' })
*/
...
...
@@ -85,8 +90,8 @@ class Logger {
/**
* @description You can use to show deprecated messages, old API or functions
* @function warning
* @param message any type of message
* @param context Context will use to handle params. For example user IP address, username etc.
* @param message
-
any type of message
* @param context
-
Context will use to handle params. For example user IP address, username etc.
* @example
* loggerInstance.warning('Warning User', { username: 'John' })
*/
...
...
@@ -101,8 +106,8 @@ class Logger {
/**
* @description Runtime errors, for example when parseInt or toFixed errors work wrong
* @function error
* @param message any type of message
* @param context Context will use to handle params. For example user IP address, username etc.
* @param message
-
any type of message
* @param context
-
Context will use to handle params. For example user IP address, username etc.
* @example
* loggerInstance.error('Error User', { username: 'John' })
*/
...
...
@@ -117,8 +122,8 @@ class Logger {
/**
* @description Components unavailable or unexpected exceptions
* @function critical
* @param message any type of message
* @param context Context will use to handle params. For example user IP address, username etc.
* @param message
-
any type of message
* @param context
-
Context will use to handle params. For example user IP address, username etc.
* @example
* loggerInstance.critical('Critical message User', { username: 'John' })
*/
...
...
@@ -133,8 +138,8 @@ class Logger {
/**
* @description Action must be taken immediately.
* @function alert
* @param message any type of message
* @param context Context will use to handle params. For example user IP address, username etc.
* @param message
-
any type of message
* @param context
-
Context will use to handle params. For example user IP address, username etc.
* @example
* loggerInstance.alert('Alert message User', { username: 'John' })
*/
...
...
@@ -149,8 +154,8 @@ class Logger {
/**
* @description System is unusable
* @function emergency
* @param message any type of message
* @param context Context will use to handle params. For example user IP address, username etc.
* @param message
-
any type of message
* @param context
-
Context will use to handle params. For example user IP address, username etc.
* @example
* 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