mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Add log_line_prefix option 'n' for Unix epoch.
Prints time as Unix epoch with milliseconds. Tomas Vondra, reviewed by Fabien Coelho.
This commit is contained in:
		@@ -4629,6 +4629,11 @@ local0.*    /var/log/postgresql
 | 
				
			|||||||
             <entry>Time stamp with milliseconds</entry>
 | 
					             <entry>Time stamp with milliseconds</entry>
 | 
				
			||||||
             <entry>no</entry>
 | 
					             <entry>no</entry>
 | 
				
			||||||
            </row>
 | 
					            </row>
 | 
				
			||||||
 | 
					            <row>
 | 
				
			||||||
 | 
					             <entry><literal>%n</literal></entry>
 | 
				
			||||||
 | 
					             <entry>Time stamp with milliseconds (as a Unix epoch)</entry>
 | 
				
			||||||
 | 
					             <entry>no</entry>
 | 
				
			||||||
 | 
					            </row>
 | 
				
			||||||
            <row>
 | 
					            <row>
 | 
				
			||||||
             <entry><literal>%i</literal></entry>
 | 
					             <entry><literal>%i</literal></entry>
 | 
				
			||||||
             <entry>Command tag: type of session's current command</entry>
 | 
					             <entry>Command tag: type of session's current command</entry>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2438,6 +2438,20 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
 | 
				
			|||||||
						appendStringInfoString(buf, strfbuf);
 | 
											appendStringInfoString(buf, strfbuf);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
 | 
								case 'n':
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										struct	timeval tv;
 | 
				
			||||||
 | 
										char	strfbuf[128];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										gettimeofday(&tv, NULL);
 | 
				
			||||||
 | 
										sprintf(strfbuf, "%ld.%03d", tv.tv_sec, (int)(tv.tv_usec / 1000));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										if (padding != 0)
 | 
				
			||||||
 | 
											appendStringInfo(buf, "%*s", padding, strfbuf);
 | 
				
			||||||
 | 
										else
 | 
				
			||||||
 | 
											appendStringInfoString(buf, strfbuf);
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
			case 's':
 | 
								case 's':
 | 
				
			||||||
				if (formatted_start_time[0] == '\0')
 | 
									if (formatted_start_time[0] == '\0')
 | 
				
			||||||
					setup_formatted_start_time();
 | 
										setup_formatted_start_time();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -425,6 +425,7 @@
 | 
				
			|||||||
					#   %p = process ID
 | 
										#   %p = process ID
 | 
				
			||||||
					#   %t = timestamp without milliseconds
 | 
										#   %t = timestamp without milliseconds
 | 
				
			||||||
					#   %m = timestamp with milliseconds
 | 
										#   %m = timestamp with milliseconds
 | 
				
			||||||
 | 
										#   %n = timestamp with milliseconds (as a Unix epoch)
 | 
				
			||||||
					#   %i = command tag
 | 
										#   %i = command tag
 | 
				
			||||||
					#   %e = SQL state
 | 
										#   %e = SQL state
 | 
				
			||||||
					#   %c = session ID
 | 
										#   %c = session ID
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user