Introduction
Before. NET, we were always looking for a way to log current method name in a log file for better logging. but, there were no functionalities that cocould have helped in this, and it was left as an uncompleted job.
But, with. NET, we
When I was talking to NS, he showed me a piece of code:
Night_stalker wrote
See a method shorthand trick
IRB Code
IRB (main):004:0> "Hello World"-SPL
=> ["Hello", "World"]
IRB (main):005:0> "Hi there Daniel". SP
= > ["Hi", "there",
So far, our MOP series has talked about all aspects of using expandometaclass, but it's worth noting that we add a method to a class at run time by Expandometaclass. Whether it's a normal method or a static method, we add a method that determines
Multiactioncontroller Default method Name resolveris to include the specified method name in the requested addressThe Multiactioncontroller class has a property Methodnameresolver, method name resolver: It has a default value
When writing the logging function, you need to record the log caller's module name, namespace name, class name, and method name, think of the use of reflection (please note the performance of the reflection), but specifically what is not understood,
------------I do not have him, but the hand is ripe, humble and foolish, and eager to be hungry-------------The last inherited Multiactioncontroller can implement multiple processing methods in a processor, but it is limited, their URL access
Obtain the call method name in. NETWhen writing logs, you must record the module name, namespace name, class name, And Method Name of the log caller. Reflection is used (when reflection is involved, pay attention to performance ), however, I do not
In PHP, subclass overload the parent class method [parent: method name], neutron parent. In PHP, subclass overload the parent class method [parent: method name]. neutron parent cannot define a function with the same name in PHP, or include a method
Java-logback Get method nameExcerpt: 78222780We are currently migrating from log4j to Logback, but we are having trouble getting the "original" method name that triggered the log.I call it "original" because we have a centralized logger class
The example in this article describes the technique for obtaining the calling method name in asp.net. Share to everyone for your reference. The implementation methods are as follows:
In the Write log function, you need to record the log caller's
Copy Code code as follows:
/**
* Get the parameter type of the reflection method based on the method name (note When using the overloaded method with the same name)
* @param obj class instance
* @param methodname Method name
* @return
*
: This article mainly introduces PHP to obtain the current class name, function name, and method name. if you are interested in the PHP Tutorial, refer to it.
PHP retrieves several method names of the current class name
PHP gets, checks the class name, function name, method name function method
This article mainly introduces the PHP acquisition, check the class name, function name, method name of the function method, this article summarizes the function of 7
// Test log protected void writeerror (Object sender, eventargs e) {string typename = This. getType (). tostring (); // when the class name is used // string methodname = new system. diagnostics. stacktrace (true ). getframe (1 ). getmethod ().
------------I do not have him, but the hand is ripe, humble and foolish, and eager to be hungry-------------Maybe we've seen one way before. http://localhost:8080/Project name/Background servlet?actionname=login&uname=admin&upwd=123In this way the
/* * 1. Gets the class name, method name, and line number of the currently running code, mainly through the Java.lang.StackTraceElement class * * 2. Get caller, current method name* [1] Get the caller's method name, same as new Throwable* String
Obtain the call method name in ASP. NET
You need to add the corresponding namespace:
Copy the Code as follows:
Using System;
Using System. Diagnostics;
Using System. Reflection;
If you only get the current method name, you can use the following code:
Php obtains and checks the class name, function name, and method name function method, and php function name. Function methods used by php to obtain and check the class name, function name, and method name. php function name 1. function_exists
PHP Neutron class overloads the parent class method "Parent:: Method Name", Neutron parent
You cannot define a function in PHP that has the same name, or a method that cannot be defined in the same class, so there is no method overload. A method
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.