Checks that VLOG() is only used for defining a logging level. For example, VLOG(2) is correct. VLOG(INFO), VLOG(WARNING), VLOG(ERROR), and VLOG(FATAL) are not. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. lin
(filename, clean_lines, linenum, error)
| 2893 | |
| 2894 | |
| 2895 | def CheckVlogArguments(filename, clean_lines, linenum, error): |
| 2896 | """Checks that VLOG() is only used for defining a logging level. |
| 2897 | |
| 2898 | For example, VLOG(2) is correct. VLOG(INFO), VLOG(WARNING), VLOG(ERROR), and |
| 2899 | VLOG(FATAL) are not. |
| 2900 | |
| 2901 | Args: |
| 2902 | filename: The name of the current file. |
| 2903 | clean_lines: A CleansedLines instance containing the file. |
| 2904 | linenum: The number of the line to check. |
| 2905 | error: The function to call with any errors found. |
| 2906 | """ |
| 2907 | line = clean_lines.elided[linenum] |
| 2908 | if re.search(r"\bVLOG\((INFO|ERROR|WARNING|DFATAL|FATAL)\)", line): |
| 2909 | error( |
| 2910 | filename, |
| 2911 | linenum, |
| 2912 | "runtime/vlog", |
| 2913 | 5, |
| 2914 | "VLOG() should be used with numeric verbosity level. " |
| 2915 | "Use LOG() if you want symbolic severity levels.", |
| 2916 | ) |
| 2917 | |
| 2918 | |
| 2919 | # Matches invalid increment: *count++, which moves pointer instead of |