Skip to content

Commit

Permalink
print logs to stdout instead of loki
Browse files Browse the repository at this point in the history
  • Loading branch information
nikmel2803 committed Nov 21, 2023
1 parent 66b9547 commit 02a1a23
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 239 deletions.
4 changes: 0 additions & 4 deletions packages/cli/src/config/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ export const bundlerArgsSchema = z.object({
logLevel: z.enum(["trace", "debug", "info", "warn", "error", "fatal"]),
logEnvironment: z.enum(["production", "development"]),

lokiHost: z.string().optional(),
lokiUsername: z.string().optional(),
lokiPassword: z.string().optional(),

tenderlyEnabled: z.boolean().optional(),
noEip1559Support: z.boolean()
})
Expand Down
14 changes: 1 addition & 13 deletions packages/cli/src/config/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const bundlerOptions: CliCommandOptions<IBundlerArgsInput> = {
description: "Log level",
type: "string",
require: true,
default: "trace"
default: "debug"
},
environment: {
description: "Environment",
Expand All @@ -106,18 +106,6 @@ export const bundlerOptions: CliCommandOptions<IBundlerArgsInput> = {
require: true,
default: "production"
},
lokiHost: {
description: "Loki host",
type: "string"
},
lokiUsername: {
description: "Loki username",
type: "string"
},
lokiPassword: {
description: "Loki password",
type: "string"
},
tenderlyEnabled: {
description: "Rpc url is a tenderly url",
type: "boolean",
Expand Down
8 changes: 1 addition & 7 deletions packages/cli/src/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,7 @@ export const bundlerHandler = async (args: IBundlerArgsInput): Promise<void> =>
logger = initDebugLogger(parsedArgs.logLevel)
} else {
logger = initProductionLogger(
parsedArgs.logLevel,
chainId,
chain.name,
parsedArgs.environment,
parsedArgs.lokiHost,
parsedArgs.lokiUsername,
parsedArgs.lokiPassword
parsedArgs.logLevel
)
}
const validator = new UnsafeValidator(
Expand Down
1 change: 0 additions & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"axios": "^1.3.6",
"pino": "^8.15.0",
"pino-http": "^8.4.0",
"pino-loki": "^2.1.3",
"pino-pretty": "^10.0.0",
"prom-client": "^14.2.0",
"viem": "^1.10.8",
Expand Down
46 changes: 9 additions & 37 deletions packages/utils/src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logger, { pino, Logger, SerializerFn } from "pino"
import logger, { Logger, SerializerFn } from "pino"
import { toHex } from "viem"
import "pino-loki"

// customFormatter.ts
type AnyObject = { [key: string]: any }
Expand Down Expand Up @@ -63,40 +62,13 @@ export const initDebugLogger = (level = "debug"): Logger => {
}

export const initProductionLogger = (
level: string,
chainId: number,
network: string,
environment: string,
lokiHost?: string,
lokiUsername?: string,
lokiPassword?: string
level: string
): Logger => {
if (lokiHost && lokiUsername && lokiPassword) {
const transport = pino.transport({
target: "pino-loki",
options: {
batching: true,
interval: 1,
labels: { app: "alto", chainId: chainId.toString(), env: environment, network },
host: lokiHost,
basicAuth: {
username: lokiUsername,
password: lokiPassword
},
replaceTimestamp: false
}
})

const l = logger(transport)
l.level = level
return l
} else {
const l = logger({
formatters: {
log: customSerializer
}
})
l.level = level
return l
}
const l = logger({
formatters: {
log: customSerializer
}
})
l.level = level
return l
}
Loading

0 comments on commit 02a1a23

Please sign in to comment.