Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cc-node
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
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
Mirror
cc-node
Commits
b03c7b74
Commit
b03c7b74
authored
13 years ago
by
Thibault VINCENT
Browse files
Options
Downloads
Patches
Plain Diff
add: node instance id in logs
parent
645e3abf
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/cc-node
+31
-13
31 additions, 13 deletions
bin/cc-node
with
31 additions
and
13 deletions
bin/cc-node
+
31
−
13
View file @
b03c7b74
...
...
@@ -46,13 +46,9 @@ def authentication(node, suicide, login, password):
timeout
=
MAX_AUTH_TIMEOUT
sleep
(
exp
(
timeout
))
def
run_node
(
options
):
def
setup_logging
(
options
,
instance_id
=
None
):
'''
'''
# instance life signal
suicide_event
=
threading
.
Event
()
# setup logging facility:
level
=
logging
.
ERROR
verb
=
int
(
options
[
'
verbosity
'
])
if
verb
:
...
...
@@ -70,23 +66,41 @@ def run_node(options):
facility
=
logging
.
handlers
.
SysLogHandler
.
LOG_DAEMON
handler
=
logging
.
handlers
.
SysLogHandler
(
address
=
'
/dev/log
'
,
facility
=
facility
)
fmt
=
'
cc-node: %(levelname)s
'
if
options
[
'
verbosity
'
]
==
0
:
fmt
=
'
cc-node: %(levelname)s
%(message)s
'
fmt
+
=
'
%(message)s
'
else
:
if
isinstance
(
instance_id
,
int
):
fmt
+=
'
id=%i
'
%
instance_id
if
options
[
'
stdout
'
]:
fmt
=
(
"
cc-node: %(levelname)s
\x1B
[30;47m%(process)d
\x1B
[0m:
"
"
\x1B
[30;42m%(threadName)s
\x1B
[0m:
\x1B
[30;43m%(funcName)s
"
"
\x1B
[0m:
\x1B
[30;44m%(lineno)d
\x1B
[0m@
\x1B
[30;45m%(msecs)d
"
"
\x1B
[0m
\t\t
%(message)s
"
)
fmt
+=
(
"
\x1B
[30;47m%(process)d
\x1B
[0m:
"
"
\x1B
[30;42m%(threadName)s
\x1B
[0m:
"
"
\x1B
[30;43m%(funcName)s
\x1B
[0m:
"
"
\x1B
[30;44m%(lineno)d
\x1B
[0m@
"
"
\x1B
[30;45m%(msecs)d
"
"
\x1B
[0m
\t\t
"
"
%(message)s
"
)
else
:
fmt
=
(
"
cc-node: %(levelname)s %(process)d:%(threadName)s:
"
"
%(funcName)s:%(lineno)d@%(msecs)d %(message)s
"
)
fmt
+=
(
"
%(process)d:
"
"
%(threadName)s:
"
"
%(funcName)s:
"
"
%(lineno)d@
"
"
%(msecs)d
"
"
%(message)s
"
)
handler
.
setFormatter
(
logging
.
Formatter
(
fmt
))
logger
.
handlers
=
[]
logger
.
addHandler
(
handler
)
def
run_node
(
options
):
'''
'''
# instance death event
suicide_event
=
threading
.
Event
()
# start node
try
:
# setup logging infrastructure
setup_logging
(
options
)
# create client
logging
.
debug
(
'
Initializing client
'
)
try
:
...
...
@@ -98,6 +112,10 @@ def run_node(options):
logging
.
error
(
'
Client initialization failure: `%s`:`%s`
'
,
repr
(
err
),
err
)
raise
err
# reconfigure logging with instance ID
setup_logging
(
options
,
instance_id
=
id
(
node
))
# auth thread
logging
.
debug
(
'
Starting authentication thread
'
)
auth_thread
=
threading
.
Thread
(
target
=
authentication
,
name
=
'
Auth
'
,
...
...
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