Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rocket.Chat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RocketChat
Rocket.Chat
Commits
c9b4159e
Commit
c9b4159e
authored
9 years ago
by
Rodrigo Nascimento
Browse files
Options
Downloads
Patches
Plain Diff
Add new type of logs (box) and new log method (success)
parent
8f6922df
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/rocketchat-logger/server.coffee
+55
-2
55 additions, 2 deletions
packages/rocketchat-logger/server.coffee
with
55 additions
and
2 deletions
packages/rocketchat-logger/server.coffee
+
55
−
2
View file @
c9b4159e
...
...
@@ -59,6 +59,10 @@
name
:
'info'
color
:
'blue'
level
:
1
success
:
name
:
'info'
color
:
'green'
level
:
1
warn
:
name
:
'warn'
color
:
'magenta'
...
...
@@ -86,6 +90,14 @@
method
:
typeConfig
.
name
arguments
:
args
@
[
type
+
"Box"
]
=
(
args
...)
=>
@
_log
type
:
type
box
:
true
level
:
typeConfig
.
level
method
:
typeConfig
.
name
arguments
:
args
if
@
config
.
methods
?
for
method
,
typeConfig
of
@
config
.
methods
do
(
method
,
typeConfig
)
=>
...
...
@@ -181,6 +193,26 @@
return
details
makeABox
:
(
message
)
->
if
not
_
.
isArray
(
message
)
message
=
message
.
split
(
"
\n
"
)
len
=
0
for
line
in
message
len
=
Math
.
max
(
len
,
line
.
length
)
len
+=
4
text
=
message
.
map
(
msg
)
=>
return
"|"
+
s
.
lrpad
(
msg
,
len
)
+
"|"
text
=
text
.
join
(
"
\n
"
)
topLine
=
"+"
+
s
.
pad
(
''
,
len
,
'='
)
+
"+"
separator
=
"|"
+
s
.
pad
(
''
,
len
,
''
)
+
"|"
bottomLine
=
"+"
+
s
.
pad
(
''
,
len
,
'='
)
+
"+"
return
[
topLine
,
separator
,
text
,
separator
,
bottomLine
]
_log
:
(
options
)
->
if
LoggerManager
.
enabled
is
false
LoggerManager
.
addToQueue
@
,
arguments
...
...
@@ -191,8 +223,29 @@
if
LoggerManager
.
logLevel
<
options
.
level
return
options
.
arguments
.
unshift
@
getPrefix
(
options
)
console
.
log
.
apply
console
,
options
.
arguments
prefix
=
@
getPrefix
(
options
)
if
options
.
box
is
true
and
_
.
isString
(
options
.
arguments
[
0
])
color
=
undefined
if
@
defaultTypes
[
options
.
type
]
?
color
=
@
defaultTypes
[
options
.
type
].
color
box
=
@
makeABox
options
.
arguments
[
0
],
color
subPrefix
=
'➔'
if
color
?
subPrefix
=
subPrefix
[
color
]
console
.
log
subPrefix
,
prefix
for
line
in
box
if
color
?
console
.
log
subPrefix
,
line
[
color
]
else
console
.
log
subPrefix
,
line
else
options
.
arguments
.
unshift
prefix
console
.
log
.
apply
console
,
options
.
arguments
return
processString
=
(
string
,
date
)
->
if
string
[
0
]
is
'{'
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment