Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
5662e2b0
Unverified
Commit
5662e2b0
authored
4 years ago
by
Karthikeyan Singaravelan
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Remove unused code from synapse.logging.utils. (#7897)
parent
64d22802
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changelog.d/7897.misc
+2
-0
2 additions, 0 deletions
changelog.d/7897.misc
synapse/logging/utils.py
+0
-126
0 additions, 126 deletions
synapse/logging/utils.py
with
2 additions
and
126 deletions
changelog.d/7897.misc
0 → 100644
+
2
−
0
View file @
5662e2b0
Remove unused functions `time_function`, `trace_function`, `get_previous_frames`
and `get_previous_frame` from `synapse.logging.utils` module.
\ No newline at end of file
This diff is collapsed.
Click to expand it.
synapse/logging/utils.py
+
0
−
126
View file @
5662e2b0
...
...
@@ -14,9 +14,7 @@
# limitations under the License.
import
inspect
import
logging
import
time
from
functools
import
wraps
from
inspect
import
getcallargs
...
...
@@ -74,127 +72,3 @@ def log_function(f):
wrapped
.
__name__
=
func_name
return
wrapped
def
time_function
(
f
):
func_name
=
f
.
__name__
@wraps
(
f
)
def
wrapped
(
*
args
,
**
kwargs
):
global
_TIME_FUNC_ID
id
=
_TIME_FUNC_ID
_TIME_FUNC_ID
+=
1
start
=
time
.
clock
()
try
:
_log_debug_as_f
(
f
,
"
[FUNC START] {%s-%d}
"
,
(
func_name
,
id
))
r
=
f
(
*
args
,
**
kwargs
)
finally
:
end
=
time
.
clock
()
_log_debug_as_f
(
f
,
"
[FUNC END] {%s-%d} %.3f sec
"
,
(
func_name
,
id
,
end
-
start
)
)
return
r
return
wrapped
def
trace_function
(
f
):
func_name
=
f
.
__name__
linenum
=
f
.
func_code
.
co_firstlineno
pathname
=
f
.
func_code
.
co_filename
@wraps
(
f
)
def
wrapped
(
*
args
,
**
kwargs
):
name
=
f
.
__module__
logger
=
logging
.
getLogger
(
name
)
level
=
logging
.
DEBUG
frame
=
inspect
.
currentframe
()
if
frame
is
None
:
raise
Exception
(
"
Can
'
t get current frame!
"
)
s
=
frame
.
f_back
to_print
=
[
"
\t
%s:%s %s. Args: args=%s, kwargs=%s
"
%
(
pathname
,
linenum
,
func_name
,
args
,
kwargs
)
]
while
s
:
if
True
or
s
.
f_globals
[
"
__name__
"
].
startswith
(
"
synapse
"
):
filename
,
lineno
,
function
,
_
,
_
=
inspect
.
getframeinfo
(
s
)
args_string
=
inspect
.
formatargvalues
(
*
inspect
.
getargvalues
(
s
))
to_print
.
append
(
"
\t
%s:%d %s. Args: %s
"
%
(
filename
,
lineno
,
function
,
args_string
)
)
s
=
s
.
f_back
msg
=
"
\n
Traceback for %s:
\n
"
%
(
func_name
,)
+
"
\n
"
.
join
(
to_print
)
record
=
logging
.
LogRecord
(
name
=
name
,
level
=
level
,
pathname
=
pathname
,
lineno
=
lineno
,
msg
=
msg
,
args
=
(),
exc_info
=
None
,
)
logger
.
handle
(
record
)
return
f
(
*
args
,
**
kwargs
)
wrapped
.
__name__
=
func_name
return
wrapped
def
get_previous_frames
():
frame
=
inspect
.
currentframe
()
if
frame
is
None
:
raise
Exception
(
"
Can
'
t get current frame!
"
)
s
=
frame
.
f_back
.
f_back
to_return
=
[]
while
s
:
if
s
.
f_globals
[
"
__name__
"
].
startswith
(
"
synapse
"
):
filename
,
lineno
,
function
,
_
,
_
=
inspect
.
getframeinfo
(
s
)
args_string
=
inspect
.
formatargvalues
(
*
inspect
.
getargvalues
(
s
))
to_return
.
append
(
"
{{ %s:%d %s - Args: %s }}
"
%
(
filename
,
lineno
,
function
,
args_string
)
)
s
=
s
.
f_back
return
"
,
"
.
join
(
to_return
)
def
get_previous_frame
(
ignore
=
[]):
frame
=
inspect
.
currentframe
()
if
frame
is
None
:
raise
Exception
(
"
Can
'
t get current frame!
"
)
s
=
frame
.
f_back
.
f_back
while
s
:
if
s
.
f_globals
[
"
__name__
"
].
startswith
(
"
synapse
"
):
if
not
any
(
s
.
f_globals
[
"
__name__
"
].
startswith
(
ig
)
for
ig
in
ignore
):
filename
,
lineno
,
function
,
_
,
_
=
inspect
.
getframeinfo
(
s
)
args_string
=
inspect
.
formatargvalues
(
*
inspect
.
getargvalues
(
s
))
return
"
{{ %s:%d %s - Args: %s }}
"
%
(
filename
,
lineno
,
function
,
args_string
,
)
s
=
s
.
f_back
return
None
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