GithubHelp home page GithubHelp logo

global-logging-template's Introduction

Overview

Important This is designed to be used as a template. Take a look at the .inc and, especially, the "Using the Template" part!

Since macros like $$$LOGINFO, $$$LOGSTATUS and so on are only available in Ensemble enabled namespaces, having a fallback logging strategy can be useful, especially for development purposes.

This template was created for this use case specifically. You can use it while working with Cache without Ensemble, while messing around in ZAUTHENTICATE or while debugging things in namespaces where Ensemble is not available.

Using the Template

Using the template is quite simple:

  1. Copy the code of the HBT.DemoLogging.inc into an include (.inc) file, for example MyApplication.Logging.inc
  2. Change the routine name (HBT.DemoLogging) to the name you chose for the file minus the .inc, for example MyApplication.Logging
  3. Find and replace on this file, replace HBT.DemoLog with the name your logging global is supposed to have, for example MyApplication.Log
  4. Find and replace on this file, replace LogDemo with the name you want your macros to have, for example LogMyApplication
  5. Save and Compile

Usage

Once you have compiled the Routine, assuming you named it MyApplication.Logging, you can include it like any other macro: include (HBT.DemoLogging) And then you have access to the following macros:

  • $$$LogMyApplicationError
  • $$$LogMyApplicationWarn
  • $$$LogMyApplicationInfo
  • $$$LogMyApplicationDebug
  • $$$LogMyApplicationTrace

Which you can call like this:

set tResult = <some-of-your-code-that-does-something>
$$$LogMyApplicationInfo("Result of my code is: "_tResult)

Enabling Logging

By default, not log output is written. You will have to enable it first, with a level you want to choose. Levels go from Off (0) to Trace (5), and a higher log level always includes all the lower ones.

To enable logging, open an IRIS session in the namespace you want to use it in, and execute this:

set ^MyApplication.Log = 5

where MyApplication.Log is the name of the global you chose. This will set the logging level to 5, which is trace (See the macro file for a list of logging levels and their numbers)

To disable logging, you can either kill the global (kill ^MyApplication.Log) or set the logging level to off (set ^MyApplication.Log = 0). The first will also remove the log history, the second will preserve it and just not log more.

Viewing the Logs

There are two ways to view the output:

Other

Please let me know if you have any improvements for this. Feel free to comment on the gist, fork or do whatever you want with this!

global-logging-template's People

Contributors

niklas345 avatar

Watchers

James Cloos avatar Henning 海宁 Voss avatar  avatar  avatar

global-logging-template's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.