Skip to content

Commit

Permalink
Merge pull request #211 from axiomhq/log-from-event-handler
Browse files Browse the repository at this point in the history
docs (logger-example): add example of logging from an event handler, and .env-example file
  • Loading branch information
dasfmi authored Jul 16, 2024
2 parents 7a4ca5e + 5d9f4e1 commit 6e83d87
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/logger/.env-example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NEXT_PUBLIC_AXIOM_DATASET=""
NEXT_PUBLIC_AXIOM_TOKEN=""
2 changes: 2 additions & 0 deletions examples/logger/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

.env

# dependencies
/node_modules
/.pnp
Expand Down
5 changes: 5 additions & 0 deletions examples/logger/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ function Home() {

logger.info('Hello from client', { foo: 'bar' });

const logFromEventHandler = () => {
logger.info('Hello from event handler', { foo: 'bar' });
};

return (
<main className={styles.main}>
<h1>
Expand All @@ -17,6 +21,7 @@ function Home() {
<h1>
<Link href="/worker">Worker</Link>
</h1>
<button onClick={logFromEventHandler}>Log from event handler</button>
</main>
);
}
Expand Down

0 comments on commit 6e83d87

Please sign in to comment.