Merge pull request #30883 from mortiy/master

Use pino-pretty options as PrettyOptions
This commit is contained in:
Mine Starks
2018-11-28 07:23:51 -08:00
committed by GitHub
2 changed files with 37 additions and 7 deletions
+24 -7
View File
@@ -5,6 +5,7 @@
// Christian Rackerseder <https://github.com/screendriver>
// GP <https://github.com/paambaati>
// Alex Ferrando <https://github.com/alferpal>
// Oleksandr Sidko <https://github.com/mortiy>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -243,13 +244,12 @@ declare namespace P {
interface PrettyOptions {
/**
* If set to true, it will only covert the unix timestamp to ISO 8601 date format, and reserialize the JSON (equivalent to pino -t).
* Translate the epoch time value into a human readable date and time string.
* This flag also can set the format string to apply when translating the date to human readable format.
* The default format is yyyy-mm-dd HH:MM:ss.l o in UTC.
* For a list of available pattern letters see the {@link https://www.npmjs.com/package/dateformat|dateformat documentation}.
*/
timeTransOnly?: boolean;
/**
* A custom function to format the line, is passed the JSON object as an argument and should return a string value.
*/
formatter?(log: LogDescriptor): string;
translateTime?: boolean | string;
/**
* If set to true, it will print the name of the log level as the first field in the log line. Default: `false`.
*/
@@ -261,7 +261,24 @@ declare namespace P {
/**
* If set to true, will add color information to the formatted output message. Default: `false`.
*/
forceColor?: boolean;
colorize?: boolean;
/**
* Appends carriage return and line feed, instead of just a line feed, to the formatted log line.
*/
crlf?: boolean;
/**
* Define the log keys that are associated with error like objects. Default: ["err", "error"]
*/
errorLikeObjectKeys?: string[];
/**
* When formatting an error object, display this list of properties.
* The list should be a comma separated list of properties. Default: ''
*/
errorProps?: string;
/**
* Specify a search pattern according to {@link http://jmespath.org|jmespath}
*/
search?: string;
}
type Level = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace';
+13
View File
@@ -123,3 +123,16 @@ anotherRedacted.info({
msg: 'another logged with redacted properties',
anotherPath: 'Not shown'
});
const pretty = pino({
prettyPrint: {
colorize: true,
crlf: false,
errorLikeObjectKeys: ['err', 'error'],
errorProps: '',
levelFirst: false,
messageKey: 'msg',
translateTime: 'UTC:h:MM:ss TT Z',
search: 'foo == `bar`'
}
});