Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nodejs-logger
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirera
nodejs-logger
Commits
738f5a41
Commit
738f5a41
authored
Sep 21, 2016
by
Данила Ерёмин
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stack with line breaks
parent
7a4058b0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
31 deletions
+17
-31
index.js
index.js
+16
-30
package.json
package.json
+1
-1
No files found.
index.js
View file @
738f5a41
...
...
@@ -9,6 +9,8 @@ if (!('toJSON' in Error.prototype))
Object
.
getOwnPropertyNames
(
this
).
forEach
(
function
(
key
)
{
alt
[
key
]
=
this
[
key
];
if
(
key
===
'
stack
'
)
alt
[
key
]
=
alt
[
key
].
split
(
'
\n
'
);
},
this
);
return
alt
;
...
...
@@ -21,6 +23,15 @@ const fs = require('fs');
const
path
=
require
(
'
path
'
);
const
logger
=
{
_makeString
:
function
(
args
)
{
let
string
=
''
;
for
(
var
i
=
0
;
i
<
args
.
length
;
i
++
)
{
string
+=
JSON
.
stringify
(
args
[
i
],
""
,
4
)
+
'
'
;
}
return
string
;
},
_console
:
function
(
string
)
{
if
(
this
.
_loggers
.
indexOf
(
this
.
CONSOLE
)
>=
0
)
{
console
.
log
(
string
);
...
...
@@ -39,12 +50,7 @@ const logger = {
},
debug
:
function
()
{
let
string
=
''
;
for
(
var
i
=
0
;
i
<
arguments
.
length
;
i
++
)
{
string
+=
JSON
.
stringify
(
arguments
[
i
])
+
'
'
;
}
let
str
=
this
.
_prefix
+
'
\
033[34m Debug:
\
033[30m
'
+
string
;
let
str
=
this
.
_prefix
+
'
\
033[34m Debug:
\
033[30m
'
+
this
.
_makeString
(
arguments
);
if
(
this
.
_level
>=
this
.
DEBUG
)
{
this
.
_console
(
str
);
this
.
_file
(
str
);
...
...
@@ -52,12 +58,7 @@ const logger = {
}
},
info
:
function
()
{
let
string
=
''
;
for
(
var
i
=
0
;
i
<
arguments
.
length
;
i
++
)
{
string
+=
JSON
.
stringify
(
arguments
[
i
])
+
'
'
;
}
let
str
=
this
.
_prefix
+
'
\
033[32m Info:
\
033[30m
'
+
string
;
let
str
=
this
.
_prefix
+
'
\
033[32m Info:
\
033[30m
'
+
this
.
_makeString
(
arguments
);
if
(
this
.
_level
>=
this
.
INFO
)
{
this
.
_console
(
str
);
this
.
_file
(
str
);
...
...
@@ -65,12 +66,7 @@ const logger = {
}
},
warning
:
function
()
{
let
string
=
''
;
for
(
var
i
=
0
;
i
<
arguments
.
length
;
i
++
)
{
string
+=
JSON
.
stringify
(
arguments
[
i
])
+
'
'
;
}
let
str
=
this
.
_prefix
+
'
\
033[33m Warning:
\
033[30m
'
+
string
;
let
str
=
this
.
_prefix
+
'
\
033[33m Warning:
\
033[30m
'
+
this
.
_makeString
(
arguments
);
if
(
this
.
_level
>=
this
.
WARNING
)
{
this
.
_console
(
str
);
this
.
_file
(
str
);
...
...
@@ -78,12 +74,7 @@ const logger = {
}
},
error
:
function
()
{
let
string
=
''
;
for
(
var
i
=
0
;
i
<
arguments
.
length
;
i
++
)
{
string
+=
JSON
.
stringify
(
arguments
[
i
])
+
'
'
;
}
let
str
=
this
.
_prefix
+
'
\
033[31m Error:
\
033[30m
'
+
string
;
let
str
=
this
.
_prefix
+
'
\
033[31m Error:
\
033[30m
'
+
this
.
_makeString
(
arguments
);
if
(
this
.
_level
>=
this
.
ERROR
)
{
this
.
_console
(
str
);
this
.
_file
(
str
);
...
...
@@ -91,12 +82,7 @@ const logger = {
}
},
fatal
:
function
()
{
let
string
=
''
;
for
(
var
i
=
0
;
i
<
arguments
.
length
;
i
++
)
{
string
+=
JSON
.
stringify
(
arguments
[
i
])
+
'
'
;
}
let
str
=
this
.
_prefix
+
'
\
033[35m Fatal:
\
033[30m
'
+
string
;
let
str
=
this
.
_prefix
+
'
\
033[35m Fatal:
\
033[30m
'
+
this
.
_makeString
(
arguments
);
if
(
this
.
_level
>=
this
.
FATAL
)
{
this
.
_console
(
str
);
this
.
_file
(
str
);
...
...
package.json
View file @
738f5a41
{
"name"
:
"nodejs-logger"
,
"version"
:
"1.1.
0
"
,
"version"
:
"1.1.
1
"
,
"description"
:
"Logger for mirera node-js server"
,
"main"
:
"index.js"
,
"scripts"
:
{
...
...
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