Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

print logs to stdout instead of loki #42

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
47 changes: 10 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,14 @@ 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({
base: undefined, // do not log pid and hostname, we don't need it
formatters: {
log: customSerializer
}
})
l.level = level
return l
}
Loading
Loading